Skip to content

feat(html): include line numbers in unclosed HTML tag warnings#3096

Open
leno23 wants to merge 1 commit into
rust-lang:masterfrom
leno23:feat/html-tag-warn-line-numbers
Open

feat(html): include line numbers in unclosed HTML tag warnings#3096
leno23 wants to merge 1 commit into
rust-lang:masterfrom
leno23:feat/html-tag-warn-line-numbers

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

  • Use pulldown-cmark's into_offset_iter() when building the HTML tree so raw HTML tags record their opening line in the source markdown.
  • Extend unclosed HTML tag warnings to include the opening line and the line where the markdown element exits (or end of document).

Example warning:

WARN unclosed HTML tag `<t>` found in `chapter_1.md` (opened at line 1) while exiting Heading(H3) at line 1
HTML tags must be closed before exiting a markdown element.

Fixes #3079.

Test plan

  • cargo test -p mdbook-html
  • cargo test -p mdbook unclosed_html
  • Added unclosed_html_tags_line_numbers integration test for multi-line markdown

Made with Cursor

Use pulldown-cmark's offset iterator to record where raw HTML tags open
and report both the opening line and the exit line when a markdown
element ends with unclosed tags.

Fixes rust-lang#3079

Co-authored-by: Cursor <cursoragent@cursor.com>
@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label May 17, 2026
@leno23
Copy link
Copy Markdown
Author

leno23 commented May 17, 2026

Friendly ping from @leno23: this is one of several small, CI-green PRs queued for review (#3097#3112). No rush — happy to rebase or adjust if anything conflicts with other open work. Thanks for maintaining mdBook!

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

Labels

S-waiting-on-review Status: waiting on a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unclosed HTML tag warning should mention line numbers

2 participants