rustdoc: warn on improperly interleaved HTML/MD#158709
Conversation
|
r? @camelid rustbot has assigned @camelid. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
f995cee to
cb61eb4
Compare
|
r? lolbinarycat |
|
Sorry for the delay, I should still be able to review this within the next couple of days. r? @camelid |
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Noah Lev <[email protected]>
|
About nesting markdown tags within |
|
Yeah, I think warning makes sense since the JS won't work if it's turned into HTML. |
This is probably not what the user wants:
error: nested Markdown emphasis in HTML `style` tag
--> $DIR/invalid-html-tags-correct-script-style.rs:11:16
|
LL | /// One <style>*emph*</style>
| ^^^^^^ Markdown translates this into HTML, but the browser parses it as CSS
|
help: to turn off Markdown parsing, put the tag at the start of the line
|
LL ~ /// One
LL ~ /// <style>*emph*</style>
|
|
Okay, it's implemented. |
|
cc @rust-lang/rustdoc -- I don't think this needs an FCP since it's just adding new cases that are a natural extension to an existing lint, but pinging for visibility |
|
This is a great idea! |
…r=camelid,GuillaumeGomez
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
Rollup of 17 pull requests Successful merges: - #158168 (Added implementation on `set_permissions_nofollow` for all primary platforms) - #138618 (Support using const pointers in asm `const` operand) - #157962 (Function item should not be used as const arg) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159809 (Avoid `#[target_features]`) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate)
…r=camelid,GuillaumeGomez
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
Rollup of 16 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #157962 (Function item should not be used as const arg) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159809 (Avoid `#[target_features]`) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate)
…r=camelid,GuillaumeGomez
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
…r=camelid,GuillaumeGomez
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
Rollup of 20 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - #159853 (Updated expect messages for `CString` struct and method documentation) - #159877 (Revert "Export `derive` at `core::derive` and `std::derive`")
This comment has been minimized.
This comment has been minimized.
…uillaumeGomez
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
Rollup of 20 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - #159853 (Updated expect messages for `CString` struct and method documentation) - #159877 (Revert "Export `derive` at `core::derive` and `std::derive`")
|
@bors retry internal server error? |
…r=camelid,GuillaumeGomez
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
…uwer Rollup of 25 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159174 (Fix implicit_provenance_casts warnings on Xous) - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group) - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>) - #159673 (bootstrap: forward -fdebug-prefix-map when using cc) - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159785 (Share _Unwind_Exception definition between native and wasm) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159204 (Add support to caller_location to rustc_public) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`)
…uwer Rollup of 25 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159174 (Fix implicit_provenance_casts warnings on Xous) - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group) - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>) - #159673 (bootstrap: forward -fdebug-prefix-map when using cc) - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159785 (Share _Unwind_Exception definition between native and wasm) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159204 (Add support to caller_location to rustc_public) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`)
…uwer Rollup of 25 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159174 (Fix implicit_provenance_casts warnings on Xous) - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group) - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>) - #159673 (bootstrap: forward -fdebug-prefix-map when using cc) - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159785 (Share _Unwind_Exception definition between native and wasm) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159204 (Add support to caller_location to rustc_public) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`)
…r=camelid,GuillaumeGomez
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
…uwer Rollup of 25 pull requests Successful merges: - #159825 (codegen: handle OperandValue::Uninit in codegen_return_terminator) - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159174 (Fix implicit_provenance_casts warnings on Xous) - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group) - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>) - #159673 (bootstrap: forward -fdebug-prefix-map when using cc) - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159204 (Add support to caller_location to rustc_public) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`)
…uwer Rollup of 25 pull requests Successful merges: - #159825 (codegen: handle OperandValue::Uninit in codegen_return_terminator) - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159174 (Fix implicit_provenance_casts warnings on Xous) - #159179 (enable `unreachable_cfg_select_predicates` lint as part of `unused` lint group) - #159518 (iter: extend step_by specialization to cover StepBy<RangeIter<{integer}>>) - #159673 (bootstrap: forward -fdebug-prefix-map when using cc) - #159700 (Split non-local `semicolon_in_expressions_from_macros` into a separate lint) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159204 (Add support to caller_location to rustc_public) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159695 (proc_macro: Fix cfg_attr inner attrs in file modules) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`)
View all comments
Enhances the
rustdoc::invalid_html_tagslint 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:
This pull request makes it warn:
See also: https://talk.commonmark.org/t/thoughts-on-changing-supported-html-syntax-to-include-the-dangling-closing-angle-bracket/3827