diff options
| author | bors <bors@rust-lang.org> | 2024-09-22 07:48:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-22 07:48:56 +0000 |
| commit | 80aa6fa7314bddcfe95a68f4eb426b296bfdf4a9 (patch) | |
| tree | 1b267c6f486e10f7a0a8dd557e7520f40f369fe2 /src/librustdoc/html | |
| parent | 1f9a018fa30a13150b5e3b308d1aa16f86e27ecb (diff) | |
| parent | f314db6d6bf3f0fb8268334f2868a266c3587572 (diff) | |
| download | rust-80aa6fa7314bddcfe95a68f4eb426b296bfdf4a9.tar.gz rust-80aa6fa7314bddcfe95a68f4eb426b296bfdf4a9.zip | |
Auto merge of #130688 - workingjubilee:rollup-ovre6p7, r=workingjubilee
Rollup of 5 pull requests Successful merges: - #130648 (move enzyme flags from general cargo to rustc-specific cargo) - #130650 (Fixup Apple target's description strings) - #130664 (Generate line numbers for non-rust code examples as well) - #130665 (Prevent Deduplication of `LongRunningWarn`) - #130669 (tests: Test that `extern "C" fn` ptrs lint on slices) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/markdown.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/html/markdown/tests.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/html/static/js/main.js | 16 |
3 files changed, 14 insertions, 12 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 6f4665db6f1..050ba60318e 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -261,7 +261,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> { </pre>\ </div>", added_classes = added_classes.join(" "), - text = Escape(&original_text), + text = Escape( + original_text.strip_suffix('\n').unwrap_or(&original_text) + ), ) .into(), )); diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index e490099a92e..3ec60c0efd2 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -524,15 +524,13 @@ fn test_ascii_with_prepending_hashtag() { ####.###..#....#....#..#. #..#.#....#....#....#..#. #..#.#....#....#....#..#. -#..#.####.####.####..##.. -</code></pre></div>", +#..#.####.####.####..##..</code></pre></div>", ); t( r#"```markdown # hello ```"#, "<div class=\"example-wrap\"><pre class=\"language-markdown\"><code>\ -# hello -</code></pre></div>", +# hello</code></pre></div>", ); } diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index a0ec45b5ef3..0eba80133df 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -986,7 +986,13 @@ function preLoadCss(cssUrl) { }()); window.rustdoc_add_line_numbers_to_examples = () => { - onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => { + if (document.querySelector(".rustdoc.src")) { + // We are in the source code page, nothing to be done here! + return; + } + onEachLazy(document.querySelectorAll( + ":not(.scraped-example) > .example-wrap > pre:not(.example-line-numbers)", + ), x => { const parent = x.parentNode; const line_numbers = parent.querySelectorAll(".example-line-numbers"); if (line_numbers.length > 0) { @@ -1005,12 +1011,8 @@ function preLoadCss(cssUrl) { }; window.rustdoc_remove_line_numbers_from_examples = () => { - onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => { - const parent = x.parentNode; - const line_numbers = parent.querySelectorAll(".example-line-numbers"); - for (const node of line_numbers) { - parent.removeChild(node); - } + onEachLazy(document.querySelectorAll(".example-wrap > .example-line-numbers"), x => { + x.parentNode.removeChild(x); }); }; |
