mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 17:44:28 +00:00
rustdoc: warn on improperly interleaved HTML/MD
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:
```markdown
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:
```text
error: unopened HTML tag `svg`
--> $DIR/invalid-html-tags.rs:285:5
|
LL | /// <svg viewBox="0 0 10 10">
| ---- does not match this unclosed tag
...
LL | /// >
| - because the Markdown paragraph is interrupted by this block quote
LL | /// </svg>
| ^^^^^^ this unopened tag
```
See also: https://talk.commonmark.org/t/thoughts-on-changing-supported-html-syntax-to-include-the-dangling-closing-angle-bracket/3827