diff --git a/Cargo.toml b/Cargo.toml index 55d27fc..5dee8d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,7 @@ tracing = "0.1.35" [[example]] name = "inventory" required-features = ["inventory"] + +[[example]] +name = "html" +required-features = ["scraping"] diff --git a/examples/html.rs b/examples/html.rs index b473076..54a6c66 100644 --- a/examples/html.rs +++ b/examples/html.rs @@ -1,34 +1,29 @@ -fn main() { - // this list of used classes would ideally be parsed out of the written html, - // but i don't want to over complicate this example - let classes = [ - "mt[10rem]", - "color[#e20f00]", - "color[green]hover", - "content[attr(after)]$after", - "content['*']$before", - "color[red]$after", - ]; +use zephyr::{scraping::*, Zephyr}; - let z = zephyr::Zephyr::new(); - let css = z.generate_classes(classes); +fn main() { + let body = r#"
++ this text is red, but green on hover +
++ this text has a lot of margin +
+"#; + + let classes = get_classes(&body); + + let z = Zephyr::new(); + let css = z.generate_classes(classes.iter().map(String::as_str)); let html = format!( r#" - - - - - -- this text is red, but green on hover -
-- this text has a lot of margin -
- + + + + + {body} "# ); diff --git a/src/class.rs b/src/class.rs index a02cd8e..cf4d345 100644 --- a/src/class.rs +++ b/src/class.rs @@ -120,7 +120,7 @@ impl<'a> Class<'a> { )) } else { Ok(format!( - "{indent}{selector}{space}{{{nl}{indent2}{property}:{val}{nl}{indent}}}{nl}" + "{indent}{selector}{space}{{{nl}{indent2}{property}:{space}{val}{nl}{indent}}}{nl}" )) } } else if let Some(v) = z.declarations.get(property) { diff --git a/src/defaults.rs b/src/defaults.rs index cf5e5e9..5c613e5 100644 --- a/src/defaults.rs +++ b/src/defaults.rs @@ -45,6 +45,8 @@ pub(crate) fn default_properties() -> HashMap