|
126 | 126 | unused_qualifications, |
127 | 127 | variant_size_differences |
128 | 128 | )] |
129 | | -use crate::parse::Declaration; |
130 | 129 | use kuchiki::traits::TendrilSink; |
131 | 130 | use kuchiki::{parse_html, Selectors}; |
132 | 131 |
|
133 | 132 | pub mod error; |
134 | | -mod parse; |
| 133 | +mod parser; |
135 | 134 |
|
136 | 135 | pub use error::InlineError; |
137 | 136 | use std::collections::HashMap; |
138 | 137 |
|
139 | 138 | #[derive(Debug)] |
140 | 139 | struct Rule { |
141 | 140 | selectors: Selectors, |
142 | | - declarations: Vec<Declaration>, |
| 141 | + declarations: Vec<parser::Declaration>, |
143 | 142 | } |
144 | 143 |
|
145 | 144 | impl Rule { |
146 | | - pub fn new(selectors: &str, declarations: Vec<Declaration>) -> Result<Rule, ()> { |
| 145 | + pub fn new(selectors: &str, declarations: Vec<parser::Declaration>) -> Result<Rule, ()> { |
147 | 146 | Ok(Rule { |
148 | 147 | selectors: Selectors::compile(selectors)?, |
149 | 148 | declarations, |
@@ -211,7 +210,7 @@ impl CSSInliner { |
211 | 210 | if let Some(css_cell) = first_child.as_text() { |
212 | 211 | let css = css_cell.borrow(); |
213 | 212 | let mut parse_input = cssparser::ParserInput::new(css.as_str()); |
214 | | - let mut parser = parse::CSSParser::new(&mut parse_input); |
| 213 | + let mut parser = parser::CSSParser::new(&mut parse_input); |
215 | 214 | for parsed in parser.parse() { |
216 | 215 | if let Ok((selector, declarations)) = parsed { |
217 | 216 | let rule = Rule::new(&selector, declarations).map_err(|_| { |
@@ -262,12 +261,15 @@ pub fn inline(html: &str) -> Result<String, InlineError> { |
262 | 261 | CSSInliner::default().inline(html) |
263 | 262 | } |
264 | 263 |
|
265 | | -fn merge_styles(existing_style: &str, new_styles: &[Declaration]) -> Result<String, InlineError> { |
| 264 | +fn merge_styles( |
| 265 | + existing_style: &str, |
| 266 | + new_styles: &[parser::Declaration], |
| 267 | +) -> Result<String, InlineError> { |
266 | 268 | // Parse existing declarations in "style" attribute |
267 | 269 | let mut input = cssparser::ParserInput::new(existing_style); |
268 | 270 | let mut parser = cssparser::Parser::new(&mut input); |
269 | 271 | let declarations = |
270 | | - cssparser::DeclarationListParser::new(&mut parser, parse::CSSDeclarationListParser); |
| 272 | + cssparser::DeclarationListParser::new(&mut parser, parser::CSSDeclarationListParser); |
271 | 273 | // Merge existing with the new ones |
272 | 274 | // We know that at least one rule already exists, so we add 1 |
273 | 275 | let mut styles: HashMap<String, String> = |
|
0 commit comments