diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-10-26 13:17:13 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-26 13:17:13 +0000 |
| commit | ba2b599131218691493fc891884d4b5003a58d90 (patch) | |
| tree | 2183c6b70c448be6fd3acb41b1a1047bf2790d83 | |
| parent | ee1d6cffbfbecc99a70be77fe697af817ed6cfac (diff) | |
| parent | 31af94b73ae98e979f6e4b11a01d2a1c742f1bf4 (diff) | |
| download | rust-ba2b599131218691493fc891884d4b5003a58d90.tar.gz rust-ba2b599131218691493fc891884d4b5003a58d90.zip | |
Merge #10592
10592: Fix: only shows one # when we encounter ## r=Veykril a=dzvon Fixes #10584 Co-authored-by: Dezhi Wu <wu543065657@163.com>
| -rw-r--r-- | crates/rust-analyzer/src/markdown.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/markdown.rs b/crates/rust-analyzer/src/markdown.rs index 35eaffba8ca..59c904f86e7 100644 --- a/crates/rust-analyzer/src/markdown.rs +++ b/crates/rust-analyzer/src/markdown.rs @@ -25,6 +25,13 @@ pub(crate) fn format_docs(src: &str) -> String { } } + if in_code_block { + let trimmed = line.trim_start(); + if trimmed.starts_with("##") { + line = &trimmed[1..]; + } + } + processed_lines.push(line); } processed_lines.join("\n") @@ -136,4 +143,14 @@ let a = 1; "```text\nfiller\ntext\n```\nSome comment.\n```rust\nlet a = 1;\n```" ); } + + #[test] + fn test_format_docs_handles_escape_double_hashes() { + let comment = r#"```rust +let s = "foo +## bar # baz"; +```"#; + + assert_eq!(format_docs(comment), "```rust\nlet s = \"foo\n# bar # baz\";\n```"); + } } |
