Skip to content

Add check for correct closing method of html element - #505

Open
RoyaltyInTraining wants to merge 2 commits into
lambda-fairy:mainfrom
RoyaltyInTraining:void-element-validation
Open

Add check for correct closing method of html element#505
RoyaltyInTraining wants to merge 2 commits into
lambda-fairy:mainfrom
RoyaltyInTraining:void-element-validation

Conversation

@RoyaltyInTraining

Copy link
Copy Markdown

This addresses problems which multiple issues have mentioned (#432, #474).

The problem is: Block elements closed with ; and void elements closed with {} currently generate invalid HTML. Especially the block elements which are missing their closing tags can easily cause unexpected results after the browser attempts to silently fix the error.

This PR adds simple validation logic which emits errors when a mismatch is detected. It uses the current list of void elements in the HTML living standatd. The generation logic wasn't changed, so the output of valid usage remains identical. A html_unchecked macro is also included as an escape hatch.

@LnxgpI0k

LnxgpI0k commented Aug 3, 2026

Copy link
Copy Markdown

Does this enable optionally closing regular tags like void elements?

@RoyaltyInTraining

Copy link
Copy Markdown
Author

Does this enable optionally closing regular tags like void elements?

No, it only helps developers to write correct code by highlighting mistakes. I know that some people want the added syntax, but since this is my first contribution to this project, I chose to not touch the ast module. I'm also not sure if the repo owner even wants this additional syntax rule, or if they prefer the current 1:1 mapping to html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants