Skip to content

rustdoc: warn on improperly interleaved HTML/MD#158709

Open
notriddle wants to merge 2 commits into
rust-lang:mainfrom
notriddle:html-lint-interleaving
Open

rustdoc: warn on improperly interleaved HTML/MD#158709
notriddle wants to merge 2 commits into
rust-lang:mainfrom
notriddle:html-lint-interleaving

Conversation

@notriddle

@notriddle notriddle commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Enhances the rustdoc::invalid_html_tags lint to warn in cases where pulldown-cmark will produce invalid HTML because the Markdown and HTML are improperly nested.

As an extreme example, this code does not do what it looks like it does, and it doesn't produce a warning under current nightly, either:

Figure 1: an X
<svg viewBox="0 0 10 10">
<path
    d="M0 10L10 0M10 10L0 0"
    stroke="black"
>
</svg>

This pull request makes it warn:

error: unopened HTML tag `svg`
  --> $DIR/invalid-html-tags.rs:273:5
   |
LL |   /// Figure 1: an X
   |  _____-
LL | | /// <svg viewBox="0 0 10 10">
   | |     ---- does not match this unclosed tag
LL | | /// <path
LL | | ///     d="M0 10L10 0M10 10L0 0"
LL | | ///     stroke="black"
LL | | /// >
   | |____- because of this Markdown paragraph, which is interrupted by a block quote
LL |   /// </svg>
   |       ^^^^^^

See also: https://talk.commonmark.org/t/thoughts-on-changing-supported-html-syntax-to-include-the-dangling-closing-angle-bracket/3827

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 3, 2026
@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 3, 2026
@rustbot

rustbot commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

r? @camelid

rustbot has assigned @camelid.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 8 candidates
  • Random selection from GuillaumeGomez, camelid

@rust-log-analyzer

This comment has been minimized.

@notriddle notriddle force-pushed the html-lint-interleaving branch from f995cee to cb61eb4 Compare July 3, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants