@@ -1,3 +1,6 @@
1use std::fs;
4use std::fs;
2use std::path::Path;
5use std::path::Path;
@@ -11,7 +14,7 @@ fn compile(input: &str) -> String {
11 "unexpected parse errors: {:?}",
14 "unexpected parse errors: {:?}",
12 result.diagnostics
15 result.diagnostics
14− htmlang::codegen::generate(&result.document)
17+ codegen::generate(&result.document)
17fn compile_with_base(input: &str, base: &Path) -> String {
20fn compile_with_base(input: &str, base: &Path) -> String {
@@ -24,7 +27,7 @@ fn compile_with_base(input: &str, base: &Path) -> String {
24 "unexpected parse errors: {:?}",
27 "unexpected parse errors: {:?}",
25 result.diagnostics
28 result.diagnostics
27− htmlang::codegen::generate(&result.document)
30+ codegen::generate(&result.document)
30fn parse_diagnostics(input: &str) -> Vec<htmlang::parser::Diagnostic> {
33fn parse_diagnostics(input: &str) -> Vec<htmlang::parser::Diagnostic> {
@@ -256,7 +259,7 @@ fn error_unknown_attribute() {
259− htmlang::codegen::generate(&result.document).contains("bakground:red"),
262+ codegen::generate(&result.document).contains("bakground:red"),
260 "an unknown property is passed through"
263 "an unknown property is passed through"
@@ -313,7 +316,7 @@ fn values_pass_through_unchecked() {
313 color rebeccapurple, width fit-content, font-weight 450, display blok]\n x";
316 color rebeccapurple, width fit-content, font-weight 450, display blok]\n x";
314 let result = htmlang::parser::parse(src);
317 let result = htmlang::parser::parse(src);
315 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
318 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
316− let html = htmlang::codegen::generate(&result.document);
319+ let html = codegen::generate(&result.document);
317 for css in [
320 for css in [
318 "padding:abc",
321 "padding:abc",
319 "opacity:50%",
322 "opacity:50%",
@@ -2748,7 +2751,7 @@ fn test_variable_filters() {
2749 .all(|d| d.severity != htmlang::parser::Severity::Error)
2752 .all(|d| d.severity != htmlang::parser::Severity::Error)
2751− let html = htmlang::codegen::generate(&result.document);
2754+ let html = codegen::generate(&result.document);
2752 assert!(
2755 assert!(
2753 html.contains("HELLO"),
2756 html.contains("HELLO"),
2754 "uppercase filter should work, got: {}",
2757 "uppercase filter should work, got: {}",
@@ -2756,7 +2759,7 @@ fn test_variable_filters() {
2758 let result = htmlang::parser::parse("@let name HELLO\n@text ${lowercase($name)}");
2761 let result = htmlang::parser::parse("@let name HELLO\n@text ${lowercase($name)}");
2759− let html = htmlang::codegen::generate(&result.document);
2762+ let html = codegen::generate(&result.document);
2760 assert!(
2763 assert!(
2761 html.contains("hello"),
2764 html.contains("hello"),
2762 "lowercase filter should work, got: {}",
2765 "lowercase filter should work, got: {}",
@@ -2764,7 +2767,7 @@ fn test_variable_filters() {
2766 let result = htmlang::parser::parse("@let name hello\n@text ${capitalize($name)}");
2769 let result = htmlang::parser::parse("@let name hello\n@text ${capitalize($name)}");
2767− let html = htmlang::codegen::generate(&result.document);
2770+ let html = codegen::generate(&result.document);
2768 assert!(
2771 assert!(
2769 html.contains("Hello"),
2772 html.contains("Hello"),
2770 "capitalize filter should work, got: {}",
2773 "capitalize filter should work, got: {}",
@@ -2772,7 +2775,7 @@ fn test_variable_filters() {
2774 let result = htmlang::parser::parse("@let name hello\n@text ${length($name)}");
2777 let result = htmlang::parser::parse("@let name hello\n@text ${length($name)}");
2775− let html = htmlang::codegen::generate(&result.document);
2778+ let html = codegen::generate(&result.document);
2776 assert!(
2779 assert!(
2777 html.contains("5"),
2780 html.contains("5"),
2778 "length filter should work, got: {}",
2781 "length filter should work, got: {}",
@@ -2780,7 +2783,7 @@ fn test_variable_filters() {
2782 let result = htmlang::parser::parse("@let name hello\n@text ${reverse($name)}");
2785 let result = htmlang::parser::parse("@let name hello\n@text ${reverse($name)}");
2783− let html = htmlang::codegen::generate(&result.document);
2786+ let html = codegen::generate(&result.document);
2784 assert!(
2787 assert!(
2785 html.contains("olleh"),
2788 html.contains("olleh"),
2786 "reverse filter should work, got: {}",
2789 "reverse filter should work, got: {}",
@@ -2788,7 +2791,7 @@ fn test_variable_filters() {
2790 let result = htmlang::parser::parse("@let name hello world\n@text ${truncate($name, 5)}");
2793 let result = htmlang::parser::parse("@let name hello world\n@text ${truncate($name, 5)}");
2791− let html = htmlang::codegen::generate(&result.document);
2794+ let html = codegen::generate(&result.document);
2792 assert!(
2795 assert!(
2793 html.contains("hello..."),
2796 html.contains("hello..."),
2794 "truncate filter should work, got: {}",
2797 "truncate filter should work, got: {}",
@@ -2799,7 +2802,7 @@ fn test_variable_filters() {
2800fn test_css_shorthands_output() {
2803fn test_css_shorthands_output() {
2801 let result = htmlang::parser::parse("@text [$truncate] Hello");
2804 let result = htmlang::parser::parse("@text [$truncate] Hello");
2802− let html = htmlang::codegen::generate(&result.document);
2805+ let html = codegen::generate(&result.document);
2803 assert!(
2806 assert!(
2804 html.contains("text-overflow:ellipsis"),
2807 html.contains("text-overflow:ellipsis"),
2805 "truncate should add ellipsis, got: {}",
2808 "truncate should add ellipsis, got: {}",
@@ -2811,7 +2814,7 @@ fn test_css_shorthands_output() {
2813 let result = htmlang::parser::parse("@paragraph [line-clamp 3] Text");
2816 let result = htmlang::parser::parse("@paragraph [line-clamp 3] Text");
2814− let html = htmlang::codegen::generate(&result.document);
2817+ let html = codegen::generate(&result.document);
2815 assert!(
2818 assert!(
2816 html.contains("-webkit-line-clamp:3"),
2819 html.contains("-webkit-line-clamp:3"),
2817 "line-clamp should work, got: {}",
2820 "line-clamp should work, got: {}",
@@ -2819,7 +2822,7 @@ fn test_css_shorthands_output() {
2821 let result = htmlang::parser::parse("@el [filter blur(4px)] Content");
2824 let result = htmlang::parser::parse("@el [filter blur(4px)] Content");
2822− let html = htmlang::codegen::generate(&result.document);
2825+ let html = codegen::generate(&result.document);
2823 assert!(
2826 assert!(
2824 html.contains("filter:blur(4px)"),
2827 html.contains("filter:blur(4px)"),
2825 "blur should work, got: {}",
2828 "blur should work, got: {}",
@@ -2827,7 +2830,7 @@ fn test_css_shorthands_output() {
2829 let result = htmlang::parser::parse("@el [backdrop-filter blur(10px)] Content");
2832 let result = htmlang::parser::parse("@el [backdrop-filter blur(10px)] Content");
2830− let html = htmlang::codegen::generate(&result.document);
2833+ let html = codegen::generate(&result.document);
2831 assert!(
2834 assert!(
2832 html.contains("backdrop-filter:blur(10px)"),
2835 html.contains("backdrop-filter:blur(10px)"),
2833 "backdrop-blur should work, got: {}",
2836 "backdrop-blur should work, got: {}",
@@ -2865,7 +2868,7 @@ fn test_theme_directive() {
2865 "theme should not cause errors: {:?}",
2868 "theme should not cause errors: {:?}",
2868− let html = htmlang::codegen::generate(&result.document);
2871+ let html = codegen::generate(&result.document);
2869 assert!(
2872 assert!(
2870 html.contains("--primary:#3b82f6"),
2873 html.contains("--primary:#3b82f6"),
2871 "theme should emit CSS vars, got: {}",
2874 "theme should emit CSS vars, got: {}",
@@ -2991,7 +2994,7 @@ fn a_token_is_named_like_a_custom_property_on_an_element() {
2992fn test_autofocus_attribute() {
2995fn test_autofocus_attribute() {
2993 let result = htmlang::parser::parse("@input [type=text, autofocus]");
2996 let result = htmlang::parser::parse("@input [type=text, autofocus]");
2994− let html = htmlang::codegen::generate(&result.document);
2997+ let html = codegen::generate(&result.document);
2995 assert!(
2998 assert!(
2996 html.contains("autofocus"),
2999 html.contains("autofocus"),
2997 "autofocus should be in output, got: {}",
3000 "autofocus should be in output, got: {}",
@@ -3681,8 +3684,8 @@ fn switch_with_attrs() {
3681fn minified_output_is_smaller() {
3684fn minified_output_is_smaller() {
3682 let input = "@page Test\n@el [padding 20]\n @text [font-weight bold] Hello World\n @paragraph\n Some text here\n";
3685 let input = "@page Test\n@el [padding 20]\n @text [font-weight bold] Hello World\n @paragraph\n Some text here\n";
3683 let result = htmlang::parser::parse(input);
3686 let result = htmlang::parser::parse(input);
3684− let normal = htmlang::codegen::generate(&result.document);
3687+ let normal = codegen::generate(&result.document);
3685− let minified = htmlang::codegen::generate_minified(&result.document);
3688+ let minified = codegen::generate_minified(&result.document);
3686 assert!(
3689 assert!(
3687 minified.len() <= normal.len(),
3690 minified.len() <= normal.len(),
3688 "minified ({}) should be <= normal ({})",
3691 "minified ({}) should be <= normal ({})",
@@ -3696,8 +3699,8 @@ fn minified_output_is_smaller() {
3696fn minified_strips_comments() {
3699fn minified_strips_comments() {
3697 let input = "@page Test\n@el\n @text Hello\n";
3700 let input = "@page Test\n@el\n @text Hello\n";
3698 let result = htmlang::parser::parse(input);
3701 let result = htmlang::parser::parse(input);
3699− let dev = htmlang::codegen::generate_dev(&result.document);
3702+ let dev = codegen::generate_dev(&result.document);
3700− let minified = htmlang::codegen::generate_minified(&result.document);
3703+ let minified = codegen::generate_minified(&result.document);
3701 // Dev mode has comments, minified should not
3704 // Dev mode has comments, minified should not
3702 assert!(dev.contains("<!--"));
3705 assert!(dev.contains("<!--"));
3703 assert!(!minified.contains("<!--"));
3706 assert!(!minified.contains("<!--"));
@@ -4201,7 +4204,7 @@ fn snapshot_responsive_images() {
4201fn source_map_generation() {
4204fn source_map_generation() {
4202 let input = "@page Test\n@text [font-weight bold] Hello";
4205 let input = "@page Test\n@text [font-weight bold] Hello";
4203 let result = htmlang::parser::parse(input);
4206 let result = htmlang::parser::parse(input);
4204− let map = htmlang::codegen::generate_source_map(&result.document, "test.hl");
4207+ let map = codegen::generate_source_map(&result.document, "test.hl");
4205 assert!(
4208 assert!(
4206 map.contains("\"version\":3"),
4209 map.contains("\"version\":3"),
4207 "source map should have version 3"
4210 "source map should have version 3"
@@ -4293,7 +4296,7 @@ fn svg_directive_inline() {
4293 "should parse without errors: {:?}",
4296 "should parse without errors: {:?}",
4294 result.diagnostics
4297 result.diagnostics
4296− let html = htmlang::codegen::generate(&result.document);
4299+ let html = codegen::generate(&result.document);
4297 assert!(
4300 assert!(
4298 html.contains("<svg"),
4301 html.contains("<svg"),
4299 "should inline SVG content, got: {}",
4302 "should inline SVG content, got: {}",
@@ -4324,7 +4327,7 @@ fn svg_directive_with_attrs() {
4324 svg_path.display()
4327 svg_path.display()
4326 let result = htmlang::parser::parse(&input);
4329 let result = htmlang::parser::parse(&input);
4327− let html = htmlang::codegen::generate(&result.document);
4330+ let html = codegen::generate(&result.document);
4328 assert!(
4331 assert!(
4329 html.contains("style=\"width:24px;fill:red\""),
4332 html.contains("style=\"width:24px;fill:red\""),
4330 "should override width, got: {}",
4333 "should override width, got: {}",
@@ -4363,7 +4366,7 @@ fn css_property_directive() {
4363 "should parse without errors: {:?}",
4366 "should parse without errors: {:?}",
4364 result.diagnostics
4367 result.diagnostics
4366− let html = htmlang::codegen::generate(&result.document);
4369+ let html = codegen::generate(&result.document);
4367 assert!(
4370 assert!(
4368 html.contains("@property --my-color"),
4371 html.contains("@property --my-color"),
4369 "@property rule should be emitted, got: {}",
4372 "@property rule should be emitted, got: {}",
@@ -4389,7 +4392,7 @@ fn css_property_directive() {
4390fn partial_output() {
4393fn partial_output() {
4391 let result = htmlang::parser::parse("@page Test\n@el [padding 20]\n Hello");
4394 let result = htmlang::parser::parse("@page Test\n@el [padding 20]\n Hello");
4392− let html = htmlang::codegen::generate_partial(&result.document);
4395+ let html = codegen::generate_partial(&result.document);
4393 assert!(
4396 assert!(
4394 !html.contains("<!DOCTYPE"),
4397 !html.contains("<!DOCTYPE"),
4395 "partial should not have doctype, got: {}",
4398 "partial should not have doctype, got: {}",
@@ -4425,7 +4428,7 @@ fn partial_output() {
4426fn partial_output_dev() {
4429fn partial_output_dev() {
4427 let result = htmlang::parser::parse("@page Test\n@el [padding 20]\n Hello");
4430 let result = htmlang::parser::parse("@page Test\n@el [padding 20]\n Hello");
4428− let html = htmlang::codegen::generate_partial_dev(&result.document);
4431+ let html = codegen::generate_partial_dev(&result.document);
4429 assert!(
4432 assert!(
4430 !html.contains("<!DOCTYPE"),
4433 !html.contains("<!DOCTYPE"),
4431 "partial dev should not have doctype"
4434 "partial dev should not have doctype"
@@ -4466,7 +4469,7 @@ fn auto_image_dimensions_respects_explicit() {
4466 png_path.display()
4469 png_path.display()
4468 let result = htmlang::parser::parse(&input);
4471 let result = htmlang::parser::parse(&input);
4469− let html = htmlang::codegen::generate(&result.document);
4472+ let html = codegen::generate(&result.document);
4470 // When width/height are set as CSS attrs, auto-dimensions should not add HTML width/height
4473 // When width/height are set as CSS attrs, auto-dimensions should not add HTML width/height
4471 assert!(
4474 assert!(
4472 html.contains("width:100px"),
4475 html.contains("width:100px"),
@@ -4503,7 +4506,7 @@ fn perf_large_document() {
4503 let input = std::fs::read_to_string(dir.join("stress_large.hl")).unwrap();
4506 let input = std::fs::read_to_string(dir.join("stress_large.hl")).unwrap();
4504 let start = std::time::Instant::now();
4507 let start = std::time::Instant::now();
4505 let result = htmlang::parser::parse(&input);
4508 let result = htmlang::parser::parse(&input);
4506− let _ = htmlang::codegen::generate(&result.document);
4509+ let _ = codegen::generate(&result.document);
4507 let elapsed = start.elapsed();
4510 let elapsed = start.elapsed();
4508 assert!(
4511 assert!(
4509 elapsed.as_millis() < 5000,
4512 elapsed.as_millis() < 5000,
@@ -4576,7 +4579,7 @@ fn markdown_file_renders_content() {
4577 let input = "@markdown article.md\n";
4580 let input = "@markdown article.md\n";
4578 let result = htmlang::parser::parse_with_base(input, Some(&dir));
4581 let result = htmlang::parser::parse_with_base(input, Some(&dir));
4579− let html = htmlang::codegen::generate(&result.document);
4582+ let html = codegen::generate(&result.document);
4580 let _ = std::fs::remove_dir_all(&dir);
4583 let _ = std::fs::remove_dir_all(&dir);
4582 assert!(
4585 assert!(
@@ -4609,7 +4612,7 @@ fn markdown_file_with_variable_path() {
4610 let input = "@let file post.md\n@markdown $file\n";
4613 let input = "@let file post.md\n@markdown $file\n";
4611 let result = htmlang::parser::parse_with_base(input, Some(&dir));
4614 let result = htmlang::parser::parse_with_base(input, Some(&dir));
4612− let html = htmlang::codegen::generate(&result.document);
4615+ let html = codegen::generate(&result.document);
4613 let _ = std::fs::remove_dir_all(&dir);
4616 let _ = std::fs::remove_dir_all(&dir);
4615 assert!(
4618 assert!(
@@ -4746,7 +4749,7 @@ fn only_a_function_takes_a_body() {
4746 assert_eq!(found[0].0, 3);
4749 assert_eq!(found[0].0, 3);
4747 assert!(found[0].1.contains("`@let @card"), "{}", found[0].1);
4750 assert!(found[0].1.contains("`@let @card"), "{}", found[0].1);
4748 let result = htmlang::parser::parse(&input);
4751 let result = htmlang::parser::parse(&input);
4749− let html = htmlang::codegen::generate(&result.document);
4752+ let html = codegen::generate(&result.document);
4750 assert!(!html.contains("Body"), "{}: {}", head, html);
4753 assert!(!html.contains("Body"), "{}: {}", head, html);
@@ -4780,7 +4783,7 @@ fn a_let_needs_a_bare_name_and_a_value() {
4781 // The body of a `@let` without a value isn't rendered either
4784 // The body of a `@let` without a value isn't rendered either
4782 let result = htmlang::parser::parse("@let card\n @el Body\n");
4785 let result = htmlang::parser::parse("@let card\n @el Body\n");
4783− assert!(!htmlang::codegen::generate(&result.document).contains("Body"));
4786+ assert!(!codegen::generate(&result.document).contains("Body"));
4785 for name in ["1x", "a!b", "true"] {
4788 for name in ["1x", "a!b", "true"] {
4786 let input = format!("@let {} = 1\n", name);
4789 let input = format!("@let {} = 1\n", name);
@@ -5054,7 +5057,7 @@ fn a_parameter_passed_with_equals_is_an_error() {
5054 // Not also reported as missing, and not forwarded as an HTML attribute
5057 // Not also reported as missing, and not forwarded as an HTML attribute
5055 assert!(coded(&diags, "missing-parameter").is_empty(), "{:?}", diags);
5058 assert!(coded(&diags, "missing-parameter").is_empty(), "{:?}", diags);
5056 let result = htmlang::parser::parse("@let @card [title]\n @el $title\n@card [title=Hi]\n");
5059 let result = htmlang::parser::parse("@let @card [title]\n @el $title\n@card [title=Hi]\n");
5057− let out = htmlang::codegen::generate(&result.document);
5060+ let out = codegen::generate(&result.document);
5058 assert!(out.contains("Hi"), "{}", out);
5061 assert!(out.contains("Hi"), "{}", out);
5059 assert!(!out.contains("title=\"Hi\""), "{}", out);
5062 assert!(!out.contains("title=\"Hi\""), "{}", out);
@@ -5311,7 +5314,7 @@ fn a_function_in_its_own_callers_content_is_not_recursion() {
5311 let src = "@let @box\n @el [padding 4]\n @children\n@box\n @box\n Inner\n {@box x}\n@box {@box y}\n";
5314 let src = "@let @box\n @el [padding 4]\n @children\n@box\n @box\n Inner\n {@box x}\n@box {@box y}\n";
5312 let result = htmlang::parser::parse(src);
5315 let result = htmlang::parser::parse(src);
5313 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
5316 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
5314− let out = htmlang::codegen::generate(&result.document);
5317+ let out = codegen::generate(&result.document);
5315 // The two calls inside text are inline-flex spans
5318 // The two calls inside text are inline-flex spans
5316 assert_eq!(out.matches("<div").count(), 3, "{}", out);
5319 assert_eq!(out.matches("<div").count(), 3, "{}", out);
5317 assert_eq!(out.matches("<span class=").count(), 2, "{}", out);
5320 assert_eq!(out.matches("<span class=").count(), 2, "{}", out);
@@ -5705,7 +5708,7 @@ fn an_included_file_s_slots_are_where_its_include_is() {
5705 Some(&dir),
5708 Some(&dir),
5707 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
5710 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
5708− let html = htmlang::codegen::generate(&result.document);
5711+ let html = codegen::generate(&result.document);
5709 for text in ["Hello", "Foot", "From fillers", "Plain"] {
5712 for text in ["Hello", "Foot", "From fillers", "Plain"] {
5710 assert!(html.contains(text), "{}: {}", text, html);
5713 assert!(html.contains(text), "{}: {}", text, html);
@@ -5866,7 +5869,7 @@ fn css_if_in_a_value_is_css() {
5866 "@el [width if(media(width > 40em): 50%; else: 100%), color if(style(--dark: 1): white; else: black)]\n x\n",
5869 "@el [width if(media(width > 40em): 50%; else: 100%), color if(style(--dark: 1): white; else: black)]\n x\n",
5868 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
5871 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
5869− let html = htmlang::codegen::generate(&result.document);
5872+ let html = codegen::generate(&result.document);
5870 assert!(
5873 assert!(
5871 html.contains("width:if(media(width > 40em): 50%; else: 100%);"),
5874 html.contains("width:if(media(width > 40em): 50%; else: 100%);"),
@@ -5978,7 +5981,7 @@ fn the_after_snippet_of_names_not_values() {
5978 let unknown = coded(&result.diagnostics, "unknown-attribute");
5981 let unknown = coded(&result.diagnostics, "unknown-attribute");
5979 assert_eq!(unknown.len(), 1, "{:?}", result.diagnostics);
5982 assert_eq!(unknown.len(), 1, "{:?}", result.diagnostics);
5980 assert_eq!(unknown[0].severity, htmlang::parser::Severity::Warning);
5983 assert_eq!(unknown[0].severity, htmlang::parser::Severity::Warning);
5981− assert!(htmlang::codegen::generate(&result.document).contains("text-grow:per-line"));
5984+ assert!(codegen::generate(&result.document).contains("text-grow:per-line"));
5983 let d = parse_diagnostics("@let name Ada\n@text Hello $nmae\n");
5986 let d = parse_diagnostics("@let name Ada\n@text Hello $nmae\n");
5984 let undefined = coded(&d, "undefined-variable");
5987 let undefined = coded(&d, "undefined-variable");
@@ -6011,7 +6014,7 @@ fn unknown_css_properties_pass_through_with_a_warning() {
6011 assert_eq!(unknown[0].subject.as_deref(), Some("colr"));
6014 assert_eq!(unknown[0].subject.as_deref(), Some("colr"));
6012 assert_eq!(unknown[0].suggestion.as_deref(), Some("color"));
6015 assert_eq!(unknown[0].suggestion.as_deref(), Some("color"));
6013 assert_eq!(unknown[0].column, Some(5));
6016 assert_eq!(unknown[0].column, Some(5));
6014− let html = htmlang::codegen::generate(&result.document);
6017+ let html = codegen::generate(&result.document);
6015 for css in [
6018 for css in [
6016 "colr:red",
6019 "colr:red",
6017 "--gap:12px",
6020 "--gap:12px",
@@ -6045,7 +6048,7 @@ fn what_cannot_be_css_is_an_error_and_left_out() {
6046 result.diagnostics
6049 result.diagnostics
6048− let html = htmlang::codegen::generate(&result.document);
6051+ let html = codegen::generate(&result.document);
6049 assert!(
6052 assert!(
6050 !html.contains("center-z") && !html.contains("email"),
6053 !html.contains("center-z") && !html.contains("email"),
@@ -6103,7 +6106,7 @@ fn selector_prefixes_are_css_pseudo_classes_and_elements() {
6103 @el [not([title=\") x\"]):color blue] x\n";
6106 @el [not([title=\") x\"]):color blue] x\n";
6104 let result = htmlang::parser::parse(src);
6107 let result = htmlang::parser::parse(src);
6105 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
6108 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
6106− let html = htmlang::codegen::generate(&result.document);
6109+ let html = codegen::generate(&result.document);
6107 for css in [
6110 for css in [
6108 ":first-child{font-weight:700;}",
6111 ":first-child{font-weight:700;}",
6109 ":nth-child(odd){background:var(--subtle);}",
6112 ":nth-child(odd){background:var(--subtle);}",
@@ -6170,7 +6173,7 @@ fn values_that_would_break_out_of_the_css_rule_are_errors() {
6170 result.diagnostics
6173 result.diagnostics
6172 // The value is left out of the page
6175 // The value is left out of the page
6173− let html = htmlang::codegen::generate(&result.document);
6176+ let html = codegen::generate(&result.document);
6174 assert!(
6177 assert!(
6175 !html.contains("background blue") && !html.contains("{3}"),
6178 !html.contains("background blue") && !html.contains("{3}"),
@@ -6220,7 +6223,7 @@ fn a_style_whose_value_comes_out_empty_is_left_out() {
6220 "@data $p {\"title\": \"Hi\"}\n@let on false\n@el [padding $p.gap, margin ${if($on, 4)}, color red]\n $p.title\n",
6223 "@data $p {\"title\": \"Hi\"}\n@let on false\n@el [padding $p.gap, margin ${if($on, 4)}, color red]\n $p.title\n",
6222 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
6225 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
6223− let html = htmlang::codegen::generate(&result.document);
6226+ let html = codegen::generate(&result.document);
6224 assert!(
6227 assert!(
6225 !html.contains("padding:") && !html.contains("margin:"),
6228 !html.contains("padding:") && !html.contains("margin:"),
@@ -6330,7 +6333,7 @@ fn a_warning_in_a_loop_or_a_function_is_reported_once() {
6330fn hidden_is_a_boolean_attribute() {
6333fn hidden_is_a_boolean_attribute() {
6331 let result = htmlang::parser::parse("@el [hidden] x\n");
6334 let result = htmlang::parser::parse("@el [hidden] x\n");
6332 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
6335 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
6333− assert!(htmlang::codegen::generate(&result.document).contains("<div class=\"hl-a\" hidden>"));
6336+ assert!(codegen::generate(&result.document).contains("<div class=\"hl-a\" hidden>"));
@@ -6527,7 +6530,7 @@ fn spacing_goes_only_on_a_row_column_or_grid() {
6528 assert!(errors[0].message.contains(name), "{}: {:?}", src, errors);
6531 assert!(errors[0].message.contains(name), "{}: {:?}", src, errors);
6529 // Left out of the page
6532 // Left out of the page
6530− let out = htmlang::codegen::generate(&result.document);
6533+ let out = codegen::generate(&result.document);
6531 assert!(!out.contains("gap:"), "{}: {}", src, out);
6534 assert!(!out.contains("gap:"), "{}: {}", src, out);
6532 assert!(!out.contains("flex-wrap"), "{}: {}", src, out);
6535 assert!(!out.contains("flex-wrap"), "{}: {}", src, out);
6533 assert!(!out.contains("grid-template"), "{}: {}", src, out);
6536 assert!(!out.contains("grid-template"), "{}: {}", src, out);
@@ -6575,7 +6578,7 @@ fn fill_and_center_compile_against_the_parent_s_layout() {
6576 result.diagnostics
6579 result.diagnostics
6578− assert!(!htmlang::codegen::generate(&result.document).contains("flex:1"));
6581+ assert!(!codegen::generate(&result.document).contains("flex:1"));
@@ -7385,7 +7388,7 @@ fn an_element_inside_text_is_not_a_child_of_the_row_around_it() {
7385/// Output with the errors allowed, for tests of what an error leaves.
7388/// Output with the errors allowed, for tests of what an error leaves.
7386fn compile_anyway(input: &str) -> (String, Vec<htmlang::parser::Diagnostic>) {
7389fn compile_anyway(input: &str) -> (String, Vec<htmlang::parser::Diagnostic>) {
7387 let result = htmlang::parser::parse(input);
7390 let result = htmlang::parser::parse(input);
7388− let html = htmlang::codegen::generate_partial(&result.document);
7391+ let html = codegen::generate_partial(&result.document);
7389 (html, result.diagnostics)
7392 (html, result.diagnostics)
@@ -7740,7 +7743,7 @@ fn readable_output_adds_no_whitespace_inside_pre_and_textarea() {
7740 "@el\n @pre > @code\n a\n b\n @textarea [aria-label=x]\n c\n",
7743 "@el\n @pre > @code\n a\n b\n @textarea [aria-label=x]\n c\n",
7742 .document;
7745 .document;
7743− let out = htmlang::codegen::generate_dev(&doc);
7746+ let out = codegen::generate_dev(&doc);
7744 assert!(
7747 assert!(
7745 out.contains("><code class=\"hl-c\">a\n b</code></pre>\n"),
7748 out.contains("><code class=\"hl-c\">a\n b</code></pre>\n"),
@@ -8198,7 +8201,7 @@ fn a_custom_property_is_a_style_on_any_element_under_any_prefix() {
8198 "@el [--a 1, hover:--b 2, md:--c 3, dark:--d 4, children:--e 5, nth-child(2n):--f 6, has(.x):--g 7, print:--h 8, cq-md:--i 9]\n x\n@image [alt=x, --w 20px] a.png\n@paragraph {@em [--j 1] y}\n",
8201 "@el [--a 1, hover:--b 2, md:--c 3, dark:--d 4, children:--e 5, nth-child(2n):--f 6, has(.x):--g 7, print:--h 8, cq-md:--i 9]\n x\n@image [alt=x, --w 20px] a.png\n@paragraph {@em [--j 1] y}\n",
8200 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
8203 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
8201− let html = htmlang::codegen::generate(&result.document);
8204+ let html = codegen::generate(&result.document);
8202 for declaration in [
8205 for declaration in [
8203 "--a:1;",
8206 "--a:1;",
8204 "--b:2;",
8207 "--b:2;",
@@ -8228,7 +8231,7 @@ fn a_vendor_prefixed_property_is_a_style_under_any_prefix() {
8228 "@el [-webkit-text-stroke 1px red, hover:-webkit-text-stroke 2px red, dark:-webkit-tap-highlight-color transparent, -moz-osx-font-smoothing grayscale, -ms-overflow-style none]\n x\n",
8231 "@el [-webkit-text-stroke 1px red, hover:-webkit-text-stroke 2px red, dark:-webkit-tap-highlight-color transparent, -moz-osx-font-smoothing grayscale, -ms-overflow-style none]\n x\n",
8230 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
8233 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
8231− let html = htmlang::codegen::generate(&result.document);
8234+ let html = codegen::generate(&result.document);
8232 for declaration in [
8235 for declaration in [
8233 "-webkit-text-stroke:1px red;",
8236 "-webkit-text-stroke:1px red;",
8234 ":hover{-webkit-text-stroke:2px red;}",
8237 ":hover{-webkit-text-stroke:2px red;}",
@@ -8264,7 +8267,7 @@ fn a_custom_property_on_a_line_of_a_list_is_a_declaration() {
8264 "@el [\n padding 4,\n --surface white,\n -- a comment\n --\n color red\n]\n x\n",
8267 "@el [\n padding 4,\n --surface white,\n -- a comment\n --\n color red\n]\n x\n",
8266 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
8269 assert!(result.diagnostics.is_empty(), "{:?}", result.diagnostics);
8267− let html = htmlang::codegen::generate(&result.document);
8270+ let html = codegen::generate(&result.document);
8268 assert!(
8271 assert!(
8269 html.contains("padding:4px;--surface:white;color:red;"),
8272 html.contains("padding:4px;--surface:white;color:red;"),
@@ -8296,7 +8299,7 @@ fn a_style_an_inline_svg_can_t_take_is_an_error() {
8296 "@image [inline, width 24, color red, class=icon, aria-label=Logo, role=img] i.svg\n@image [inline, --w 2px, hover:color blue, alt=x] i.svg\n",
8299 "@image [inline, width 24, color red, class=icon, aria-label=Logo, role=img] i.svg\n@image [inline, --w 2px, hover:color blue, alt=x] i.svg\n",
8297 Some(&dir),
8300 Some(&dir),
8299− let html = htmlang::codegen::generate(&result.document);
8302+ let html = codegen::generate(&result.document);
8300 assert!(
8303 assert!(
8301 html.contains(
8304 html.contains(
8302 "<svg viewBox=\"0 0 1 1\" class=\"icon\" aria-label=\"Logo\" role=\"img\" style=\"width:24px;fill:red\">"
8305 "<svg viewBox=\"0 0 1 1\" class=\"icon\" aria-label=\"Logo\" role=\"img\" style=\"width:24px;fill:red\">"
@@ -8331,7 +8334,7 @@ fn a_style_an_inline_svg_can_t_take_is_an_error() {
8332 errors[0].message
8335 errors[0].message
8334− let html = htmlang::codegen::generate(&result.document);
8337+ let html = codegen::generate(&result.document);
8335 assert!(!html.contains("width=\"fill\""), "{}", html);
8338 assert!(!html.contains("width=\"fill\""), "{}", html);
8336 assert!(html.contains("style=\"height:2em\""), "{}", html);
8339 assert!(html.contains("style=\"height:2em\""), "{}", html);
8337 let _ = fs::remove_dir_all(&dir);
8340 let _ = fs::remove_dir_all(&dir);