about summary refs log tree commit diff
path: root/src/librustdoc/html/markdown
AgeCommit message (Collapse)AuthorLines
2025-08-14rustdoc: Allow multiple references to a single footnoteTsukasa OI-9/+24
Multiple references to a single footnote is a part of GitHub Flavored Markdown syntax (although not explicitly documented as well as regular footnotes, it is implemented in GitHub's fork of CommonMark) and not prohibited by rustdoc. cf. <https://github.com/github/cmark-gfm/blob/587a12bb54d95ac37241377e6ddc93ea0e45439b/test/extensions.txt#L762-L780> However, using it makes multiple "sup" elements with the same "id" attribute, which is invalid per the HTML specification. Still, not only this is a valid GitHub Flavored Markdown syntax, this is helpful on certain cases and actually tested (accidentally) in tests/rustdoc/footnote-reference-in-footnote-def.rs. This commit keeps track of the number of references per footnote and gives unique ID to each reference. It also emits *all* back links from a footnote to its references as "↩" (return symbol) plus a numeric list in superscript. As a known limitation, it assumes that all references to a footnote are rendered (this is not always true if a dangling footnote has one or more references but considered a reasonable compromise). Also note that, this commit is designed so that no HTML changes will occur unless multiple references to a single footnote is actually used.
2025-07-03Auto merge of #143363 - jdonszelmann:rollup-7cv1kql, r=jdonszelmannbors-2/+2
Rollup of 6 pull requests Successful merges: - rust-lang/rust#134006 (setup typos check in CI) - rust-lang/rust#142876 (Port `#[target_feature]` to new attribute parsing infrastructure) - rust-lang/rust#143038 (avoid suggesting traits from private dependencies) - rust-lang/rust#143083 (Fix rustdoc not correctly showing attributes on re-exports) - rust-lang/rust#143283 (document optional jobs) - rust-lang/rust#143329 (minicore: use core's `diagnostic::on_unimplemented` messages) Failed merges: - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-2/+2
2025-06-29Lazy-ify some markdown renderingYotam Ofek-7/+14
2025-03-27Remove and stabilize --enable-per-target-ignoresEric Huss-2/+2
This removes the `--enable-per-target-ignores` and enables it unconditionally.
2025-02-08Rustfmtbjorn3-8/+8
2024-12-31Fix typosericlehong-1/+1
Signed-off-by: ericlehong <193237094+ericlehong@users.noreply.github.com>
2024-12-05Always display first line of impl blocks even when collapsedGuillaume Gomez-9/+16
2024-11-28Fix new clippy lintsGuillaume Gomez-1/+1
2024-11-14Fix handling of footnote reference in footnote definitionGuillaume Gomez-26/+34
2024-11-13Fix duplicated footnote IDsGuillaume Gomez-14/+19
2024-10-19rustdoc: Refractor footnote handlingAlona Enraght-Moony-36/+67
2024-10-19rustdoc: Extract footnote logic into it's own module.Alona Enraght-Moony-0/+82
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-11/+11
2024-09-22Strip last backline from non-rust code examplesGuillaume Gomez-4/+2
2024-08-08rustdoc: do not run doctests with invalid langstringsMichael Howell-3/+3
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+4
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-05-01Stabilize `custom_code_classes_in_docs` featureGuillaume Gomez-5/+2
2024-02-17Fix non_local_definitions lint in rustdocUrgau-5/+0
2023-12-05Allow links in doc blocks headingsGuillaume Gomez-0/+7
2023-12-05Rework doc blocks headings by not turning them into links anymore and ↵Guillaume Gomez-12/+41
putting an anchor to their left side
2023-09-19Allow more characters in custom classesGuillaume Gomez-3/+18
2023-09-17Update tests for `custom_code_classes_in_docs` featureGuillaume Gomez-2/+5
2023-09-15Add `custom` tag for markdown codeblocksGuillaume Gomez-0/+36
2023-09-15Implement new eBNF for codeblock attributesGuillaume Gomez-51/+38
2023-09-15Add support for double quotes in markdown codeblock attributesGuillaume Gomez-0/+12
2023-09-15Add tests for `custom_code_classes_in_docs` featureGuillaume Gomez-27/+104
2023-09-15Implement custom classes for rustdoc code blocks with ↵Guillaume Gomez-0/+24
`custom_code_classes_in_docs` feature
2023-07-30Remove some unneeded `clone()` callsGuillaume Gomez-1/+1
2023-02-11rustdoc: account for intra-doc links in `<meta name="description">`Michael Howell-1/+1
2022-12-11Extend rustdoc hashtag prepended line testGuillaume Gomez-0/+8
2022-12-10Add test for non-rust code block hashtag prepended linesGuillaume Gomez-0/+37
2022-09-22rustdoc: fix unit testsMichael Howell-6/+5
2022-02-09Update rustdoc tests for headings indentGuillaume Gomez-34/+7
2022-02-09Unify headings indent and remove useless anchorGuillaume Gomez-10/+10
2022-01-28remove allow_fail test flagyuhaixin.hx-1/+0
2021-12-02Rename ID "main" into "main-content"Guillaume Gomez-4/+4
2021-10-04heading_level: u32 -> heading_offset: HeadingOffsetMukund Lakshman-3/+3
2021-10-04No need to default offset since we always override it.Mukund Lakshman-2/+2
2021-10-04Change `Markdown(...)` to `Markdown { ... }`Mukund Lakshman-4/+20
2021-10-04librustdoc: Use correct heading levels.Mukund Lakshman-16/+16
- Avoid multiple <h1>s on a page. - The <h#> tags should follow a semantic hierarchy. - Cap at h6 (no h7)
2021-09-08Auto merge of #87489 - bdalrhm:rustdoc-line-num, r=CraftSpiderbors-1/+23
`rustdoc`: compute correct line number for indented rust code blocks. This PR fixes a bug in `rustdoc` where it computes the wrong line number for indented rust code blocks (and subsequent blocks) it finds in markdown strings. To fix this issue, we decrement the line number if we find characters between the code block and the preceding line ending. I noticed this issue as I was trying to use `rustdoc` to extract examples from The Rust Reference and run them through the [Rust Model Checker](https://github.com/model-checking/rmc).
2021-08-25Add tests for `HtmlWithLimit`Noah Lev-0/+2
2021-07-26Pass correct line number for indented code blocks.Abdalrhman Mohamed-1/+23
2021-07-24Escape item search summariesNoah Lev-1/+11
I noticed that `Pin::new()`'s search summary looked off, and I realized that the reason is that it has inline code containing `Pin<P>`, which is not escaped and thus renders as a paragraph tag!
2021-06-18Update test cases for intra-doc links in summariesMichael Howell-1/+3
2021-03-09Treat header as first paragraph for shortened markdown descriptionsMichael Howell-0/+1
"The Rust Standard LibraryThe Rust Standard Library is the …" is an awful description.
2021-03-05Undo addition of boxesCamelid-1/+0
I don't think the boxing helped performance, in fact I think it potentially made it worse. The data was still being copied, but now it was through a pointer. Thinking about it more, I think boxing might only help when you're passing a big object around by value all the time, rather than the slowdown being that you're cloning it.
2021-03-05Don't unnecessarily clone some fields in `Context`Camelid-9/+3
There was no need to clone `id_map` because it was reset before each item was rendered. `deref_id_map` was not reset, but it was keyed by `DefId` and thus was unlikely to have collisions (at least for now). Now we just clone the fields that need to be cloned, and instead create fresh versions of the others.
2021-02-26Auto merge of #78429 - casey:doctest-attribute-splitting, r=jyn514bors-4/+42
[librustdoc] Only split lang string on `,`, ` `, and `\t` Split markdown lang strings into tokens on `,`. The previous behavior was to split lang strings into tokens on any character that wasn't a `_`, `_`, or alphanumeric. This is a potentially breaking change, so please scrutinize! See discussion in #78344. I noticed some test cases that made me wonder if there might have been some reason for the original behavior: ``` t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None); t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None); t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None); t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None); ``` It seemed pretty peculiar to specifically test lang strings in braces, with all the tokens prefixed by `.`. I did some digging, and it looks like the test cases were added way back in [this commit from 2014](https://github.com/rust-lang/rust/commit/3fef7a74ca9a) by `@skade.` It looks like they were added just to make sure that the splitting was permissive, and aren't testing that those strings in particular are accepted. Closes https://github.com/rust-lang/rust/issues/78344.