Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper MathML and SVG support #25

Open
Tamschi opened this issue Oct 1, 2021 · 0 comments
Open

Proper MathML and SVG support #25

Tamschi opened this issue Oct 1, 2021 · 0 comments
Labels
breaking Introduces or requests a breaking change. domain: Rust Involves Rust code. good first issue Good for newcomers Hacktoberfest A good-for-Hacktoberfest issue. This label is only maintained in October. priority: next I'll probably get to it, eventually. type: bug Something isn't working as expected work: clear A known solution is (to be) implemented.

Comments

@Tamschi
Copy link
Owner

Tamschi commented Oct 1, 2021

Describe the bug

Similarly to

lignin-html/src/lib.rs

Lines 516 to 588 in 471bb15

#[derive(Logos, PartialEq)]
enum ElementKind {
/// See <https://html.spec.whatwg.org/multipage/syntax.html#void-elements>.
#[regex("(?i)AREA")]
#[regex("(?i)BASE")]
#[regex("(?i)BR")]
#[regex("(?i)COL")]
#[regex("(?i)EMBED")]
#[regex("(?i)HR")]
#[regex("(?i)IMG")]
#[regex("(?i)INPUT")]
#[regex("(?i)LINK")]
#[regex("(?i)META")]
#[regex("(?i)PARAM")]
#[regex("(?i)SOURCE")]
#[regex("(?i)TRACK")]
#[regex("(?i)WBR")]
Void,
/// See <https://html.spec.whatwg.org/multipage/syntax.html#the-template-element-2>.
#[regex("(?i)TEMPLATE")]
Template,
/// See <https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements>.
#[regex("(?i)SCRIPT")]
#[regex("(?i)STYLE")]
RawText,
/// See <https://html.spec.whatwg.org/multipage/syntax.html#escapable-raw-text-elements>.
/// See <https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions> for special handling.
#[regex("(?i)TEXTAREA")]
EscapableRawTextTextarea,
/// See <https://html.spec.whatwg.org/multipage/syntax.html#escapable-raw-text-elements>.
#[regex("(?i)TITLE")]
EscapableRawText,
/// See <https://html.spec.whatwg.org/multipage/syntax.html#foreign-elements>.
//TODO
ForeignSelfClosing,
/// See <https://html.spec.whatwg.org/multipage/syntax.html#foreign-elements>.
//TODO
ForeignNotSelfClosing,
/// See <https://html.spec.whatwg.org/multipage/syntax.html#normal-elements>.
/// See <https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions> for special handling.
NormalPre,
/// See <https://html.spec.whatwg.org/multipage/syntax.html#normal-elements>,
/// <https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-name>
/// => <https://infra.spec.whatwg.org/#ascii-alphanumeric>
/// => <https://infra.spec.whatwg.org/#ascii-digit> | <https://infra.spec.whatwg.org/#ascii-alpha>
/// => <https://infra.spec.whatwg.org/#ascii-digit> | <https://infra.spec.whatwg.org/#ascii-upper-alpha> | <https://infra.spec.whatwg.org/#ascii-lower-alpha>.
#[regex("[0-9A-Za-z]+")]
Normal,
/// See <https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name>,
/// except that this variant occurs as continuation and may never occur first and anything [`Normal`](`ElementKind::Normal`) is exempted here.
// I'm not sure if splitting it up like this is the fastest options, but it's the most readable.
#[token(".")]
#[token("_")]
#[token("\u{00B7}")]
#[regex("[\u{C0}-\u{D6}]")]
#[regex("[\u{D8}-\u{F6}]")]
#[regex("[\u{F8}-\u{37D}]")]
#[regex("[\u{37F}-\u{1FFF}]")]
#[regex("[\u{200C}-\u{200D}]")]
#[regex("[\u{203F}-\u{2040}]")]
#[regex("[\u{2070}-\u{218F}]")]
#[regex("[\u{2C00}-\u{2FEF}]")]
#[regex("[\u{3001}-\u{D7FF}]")]
#[regex("[\u{F900}-\u{FDCF}]")]
#[regex("[\u{FDF0}-\u{FFFD}]")]
#[regex("[\u{10000}-\u{EFFFF}]")]
PotentialCustomElementNameCharacter,
/// To flag custom elements as valid, see above.
#[token("-")]
Dash,
#[error]
Invalid,
}
, which categorises HTML element, MathML and SVG elements also have to be sorted and validated based on context.

There also needs to be a way to render documents and fragments that are not HTML, so a way to specify an initial context.

To Reproduce

Not specified.

Expected behavior

Correct handling of SVG and MathML according to their current specifications.

Screenshots

Not applicable.

Additional context

A breaking API change is explicitly okay here.

@Tamschi Tamschi added type: bug Something isn't working as expected good first issue Good for newcomers domain: Rust Involves Rust code. priority: next I'll probably get to it, eventually. breaking Introduces or requests a breaking change. Hacktoberfest A good-for-Hacktoberfest issue. This label is only maintained in October. work: clear A known solution is (to be) implemented. labels Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Introduces or requests a breaking change. domain: Rust Involves Rust code. good first issue Good for newcomers Hacktoberfest A good-for-Hacktoberfest issue. This label is only maintained in October. priority: next I'll probably get to it, eventually. type: bug Something isn't working as expected work: clear A known solution is (to be) implemented.
Projects
None yet
Development

No branches or pull requests

1 participant