Auto merge of #14422 - garlicbreadcleric:rustdoc-hashes-escaping, r=HKalbasi
fix(rustdoc): don't escape double hashes outside of Rust code blocks Fixes #14376
This commit is contained in:
commit
a869ca3c29
@ -28,7 +28,7 @@ pub(crate) fn format_docs(src: &str) -> String {
|
|||||||
|
|
||||||
if in_code_block {
|
if in_code_block {
|
||||||
let trimmed = line.trim_start();
|
let trimmed = line.trim_start();
|
||||||
if trimmed.starts_with("##") {
|
if is_rust && trimmed.starts_with("##") {
|
||||||
line = &trimmed[1..];
|
line = &trimmed[1..];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,4 +154,12 @@ let s = "foo
|
|||||||
|
|
||||||
assert_eq!(format_docs(comment), "```rust\nlet s = \"foo\n# bar # baz\";\n```");
|
assert_eq!(format_docs(comment), "```rust\nlet s = \"foo\n# bar # baz\";\n```");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_format_docs_handles_double_hashes_non_rust() {
|
||||||
|
let comment = r#"```markdown
|
||||||
|
## A second-level heading
|
||||||
|
```"#;
|
||||||
|
assert_eq!(format_docs(comment), "```markdown\n## A second-level heading\n```");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user