Skip to content

Commit a869ca3

Browse files
committed
Auto merge of #14422 - garlicbreadcleric:rustdoc-hashes-escaping, r=HKalbasi
fix(rustdoc): don't escape double hashes outside of Rust code blocks Fixes #14376
2 parents 284c174 + be17eab commit a869ca3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/rust-analyzer/src/markdown.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn format_docs(src: &str) -> String {
2828

2929
if in_code_block {
3030
let trimmed = line.trim_start();
31-
if trimmed.starts_with("##") {
31+
if is_rust && trimmed.starts_with("##") {
3232
line = &trimmed[1..];
3333
}
3434
}
@@ -154,4 +154,12 @@ let s = "foo
154154

155155
assert_eq!(format_docs(comment), "```rust\nlet s = \"foo\n# bar # baz\";\n```");
156156
}
157+
158+
#[test]
159+
fn test_format_docs_handles_double_hashes_non_rust() {
160+
let comment = r#"```markdown
161+
## A second-level heading
162+
```"#;
163+
assert_eq!(format_docs(comment), "```markdown\n## A second-level heading\n```");
164+
}
157165
}

0 commit comments

Comments
 (0)