Add better handling for unbalanced HTML tags#2924
Merged
ehuss merged 6 commits intorust-lang:masterfrom Nov 6, 2025
Merged
Conversation
This checks for any unclosed elements when processing is finished. This is intended to detect invalid HTML in the source, or bugs in the tree builder. Raw HTML elements generate a warning (which in the future will be a configurable lint). All other sync errors are internal errors as they are not expected, and it would be helpful to know if they ever happen.
This changes the internal error message to a warning to let the user know that the HTML tags are unbalanced. In the future this will be a denyable lint. This is a very primitive approach of just ignoring the end tag. Ideally it should recover using the standard HTML parsing algorithm, since there is a chance that there will be a cascade of errors under certain unbalanced situations.
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.
This adds a little bit better handling when HTML tags are unbalanced or unclosed. It does not implement the HTML standard recovery algorithm, but I think this should be fine. The author mostly just needs to know that there is something wrong.