Include line numbers in unclosed HTML tag warnings - #3226
Open
mmustafasenoglu wants to merge 1 commit into
Open
mmustafasenoglu wants to merge 1 commit into
mmustafasenoglu wants to merge 1 commit into
Conversation
Track pulldown-cmark event offsets through the tree builder and record the opening line on raw HTML elements, so the warnings point at the source line instead of just the file. Fixes rust-lang#3079
Comment on lines
+28
to
+29
| .iter() | ||
| .filter(|&&b| b == b'\n') |
Member
There was a problem hiding this comment.
.split(b'\n') would be a simpler approach.
| let exit_line = line_number_at_offset(self.source, self.current_offset); | ||
| warn!( | ||
| "unclosed HTML tag `<{}>` found in `{}` while exiting {tag:?}\n\ | ||
| "unclosed HTML tag `<{}>`{} found in `{}` while exiting {tag:?} at line {exit_line}\n\ |
Member
There was a problem hiding this comment.
Suggested change
| "unclosed HTML tag `<{}>`{} found in `{}` while exiting {tag:?} at line {exit_line}\n\ | |
| "unclosed HTML tag `<{}>`{open_line} found in `{}` while exiting {tag:?} at line {exit_line}\n\ |
| let exit_line = line_number_at_offset(self.source, self.source.len()); | ||
| warn!( | ||
| "unclosed HTML tag `<{}>` found in `{}`", | ||
| "unclosed HTML tag `<{}>`{} found in `{}` at end of document (line {exit_line})", |
Member
There was a problem hiding this comment.
Suggested change
| "unclosed HTML tag `<{}>`{} found in `{}` at end of document (line {exit_line})", | |
| "unclosed HTML tag `<{}>`{open_line} found in `{}` at end of document (line {exit_line})", |
GuillaumeGomez
requested changes
Sep 22, 2026
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
This branch has not been deployed
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.
Fixes #3079
The warning only named the file, so finding the tag meant searching. Event offsets are now tracked through the tree builder and recorded on raw elements, and both warnings (while exiting, end of document) report the opening line plus the exit line.
Changes: