Context
In PR #1528, we fixed the <meta charset="utf-8"> parsing issue by adding #[facet(xml::elements)] to the Head struct's Vec fields. However, ideally we'd use #[facet(html::elements)] for consistency.
Problem
Due to Rust limitation rust-lang/rust#52234, macro-expanded macro_export macros from the current crate cannot be referred to by absolute paths. This means facet-format-html cannot use #[facet(html::elements)] in its own elements.rs module - it has to use #[facet(xml::elements)] instead.
This works because is_elements() in facet-core checks both xml::elements and html::elements, but it's not ideal from a consistency/documentation perspective.
Proposed Solution
Split into two crates:
facet-format-html: Parser, serializer, and the html:: attribute grammar (html::elements, html::text, etc.)
facet-format-html-dom: The DOM types (Html, Head, Body, Meta, Div, etc.) that can properly use #[facet(html::elements)]
This follows the same pattern that allows facet-format-xml/tests/ to use #[facet(xml::elements)] - test files compile as separate crates.
Benefits
- DOM types can use the canonical
html::elements attribute
- Cleaner separation of concerns (format implementation vs. DOM model)
- Users who only need the parser/serializer don't need to compile all DOM types
- Consistent with how users would define their own HTML types
Related
Context
In PR #1528, we fixed the
<meta charset="utf-8">parsing issue by adding#[facet(xml::elements)]to theHeadstruct's Vec fields. However, ideally we'd use#[facet(html::elements)]for consistency.Problem
Due to Rust limitation rust-lang/rust#52234, macro-expanded
macro_exportmacros from the current crate cannot be referred to by absolute paths. This meansfacet-format-htmlcannot use#[facet(html::elements)]in its ownelements.rsmodule - it has to use#[facet(xml::elements)]instead.This works because
is_elements()in facet-core checks bothxml::elementsandhtml::elements, but it's not ideal from a consistency/documentation perspective.Proposed Solution
Split into two crates:
facet-format-html: Parser, serializer, and thehtml::attribute grammar (html::elements,html::text, etc.)facet-format-html-dom: The DOM types (Html,Head,Body,Meta,Div, etc.) that can properly use#[facet(html::elements)]This follows the same pattern that allows
facet-format-xml/tests/to use#[facet(xml::elements)]- test files compile as separate crates.Benefits
html::elementsattributeRelated
<meta charset="utf-8">