Skip to content

Commit 7c35266

Browse files
Strip last backline from non-rust code examples
1 parent da88968 commit 7c35266

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: src/librustdoc/html/markdown.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
261261
</pre>\
262262
</div>",
263263
added_classes = added_classes.join(" "),
264-
text = Escape(&original_text),
264+
text = Escape(
265+
original_text.strip_suffix('\n').unwrap_or(&original_text)
266+
),
265267
)
266268
.into(),
267269
));

Diff for: src/librustdoc/html/markdown/tests.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,13 @@ fn test_ascii_with_prepending_hashtag() {
524524
####.###..#....#....#..#.
525525
#..#.#....#....#....#..#.
526526
#..#.#....#....#....#..#.
527-
#..#.####.####.####..##..
528-
</code></pre></div>",
527+
#..#.####.####.####..##..</code></pre></div>",
529528
);
530529
t(
531530
r#"```markdown
532531
# hello
533532
```"#,
534533
"<div class=\"example-wrap\"><pre class=\"language-markdown\"><code>\
535-
# hello
536-
</code></pre></div>",
534+
# hello</code></pre></div>",
537535
);
538536
}

0 commit comments

Comments
 (0)