Update nonVoids for HTML5 void elements; accept whitespace in close tags - #1
Open
JeremyIV wants to merge 3 commits into
Open
Update nonVoids for HTML5 void elements; accept whitespace in close tags#1JeremyIV wants to merge 3 commits into
JeremyIV wants to merge 3 commits into
Conversation
`source` is a WHATWG void element, so listing it as non-void made <source src=x/> compile to <source src="x"></source>, which is an HTML5 parse error. Conversely `picture`, `slot`, and `search` are ordinary (non-void) elements, so <picture/> rendered as a literal self-closed tag, which HTML5 treats as an unclosed open tag. Remove `source`; add `picture`, `slot`, `search`; also add `math` alongside `svg` under the same "commonly used" rationale. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Open tags already tolerate trailing whitespace (`sp <- many spaceChar`), but close tags did not, so `</div >` failed to parse. XML's grammar permits it: ETag ::= '</' Name S? '>'. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The Nothing (empty value) case was unhandled — unreachable from current call sites, but a latent crash. Folding it into the catch-all quoting branch makes the function total with no behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three small fixes, one commit each:
1.
nonVoidslist vs. the current WHATWG void-element listsourceis a void element, but it was listed as non-void, so<source src=x/>compiled to<source src="x"></source>— closing a void element is an HTML5 parse error.picture,slot, andsearchare ordinary elements but were missing from the list, so<picture/>rendered viarenderSelfas a literal<picture/>, which HTML5 parses as an unclosed open tag (the slash is ignored) — everything after it ends up inside the picture element.Fix: remove
source; addpicture,slot,searchin alphabetical position. I also addedmathnext tosvgunder the existing "since commonly used" comment — easy to drop that hunk if you'd rather not.After the fix:
2. Whitespace before
>in close tagsOpen tags tolerate trailing whitespace (
sp <- many spaceCharbefore the>), but close tags didn't, so</div >failed to parse. XML's grammar allows it (ETag ::= '</' Name S? '>'). Fix:void $ many spaceChar >> char '>'in the close branch. Verified that</div >,</ >, and a close tag split across lines all parse now.3.
renderAttrValtotalityThe
case BLC.uncons v of Just (x, _) | ... | __ -> ...had noNothingalternative — unreachable from current call sites (fromMaybe n vis never empty), but a latent crash. Folded the empty case into the catch-all quoting branch; no behavior change.Verification
cabal buildclean on GHC 9.14.1 / megaparsec 9.x (only pre-existing-Wx-partialwarnings).test.hxml→test.htmlfixture comparison passes after every commit (hxml < test.hxml | diff - test.html).This came out of an AI review pass Jeremy ran over your repos for fun. Every finding was verified as described above, but the usual skepticism applies.
🤖 Generated with Claude Code