Skip to content

Commit ba2b599

Browse files
bors[bot]dzvon
andauthored
Merge #10592
10592: Fix: only shows one # when we encounter ## r=Veykril a=dzvon Fixes #10584 Co-authored-by: Dezhi Wu <wu543065657@163.com>
2 parents ee1d6cf + 31af94b commit ba2b599

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

crates/rust-analyzer/src/markdown.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ pub(crate) fn format_docs(src: &str) -> String {
2525
}
2626
}
2727

28+
if in_code_block {
29+
let trimmed = line.trim_start();
30+
if trimmed.starts_with("##") {
31+
line = &trimmed[1..];
32+
}
33+
}
34+
2835
processed_lines.push(line);
2936
}
3037
processed_lines.join("\n")
@@ -136,4 +143,14 @@ let a = 1;
136143
"```text\nfiller\ntext\n```\nSome comment.\n```rust\nlet a = 1;\n```"
137144
);
138145
}
146+
147+
#[test]
148+
fn test_format_docs_handles_escape_double_hashes() {
149+
let comment = r#"```rust
150+
let s = "foo
151+
## bar # baz";
152+
```"#;
153+
154+
assert_eq!(format_docs(comment), "```rust\nlet s = \"foo\n# bar # baz\";\n```");
155+
}
139156
}

0 commit comments

Comments
 (0)