Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/syntax_highlighting/inject.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/inject.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs
index 8af0d8007d..8ac3c2da50 100644
--- a/crates/ide/src/syntax_highlighting/inject.rs
+++ b/crates/ide/src/syntax_highlighting/inject.rs
@@ -78,7 +78,8 @@ pub(super) fn ra_fixture(
Some(())
}
-const RUSTDOC_FENCE: &str = "```";
+const RUSTDOC_FENCE_LENGTH: usize = 3;
+const RUSTDOC_FENCES: [&str; 2] = ["```", "~~~"];
/// Injection of syntax highlighting of doctests.
pub(super) fn doc_comment(
@@ -166,11 +167,11 @@ pub(super) fn doc_comment(
};
let mut pos = TextSize::from(0);
- match line.find(RUSTDOC_FENCE) {
+ match RUSTDOC_FENCES.into_iter().find_map(|fence| line.find(fence)) {
Some(idx) => {
is_codeblock = !is_codeblock;
// Check whether code is rust by inspecting fence guards
- let guards = &line[idx + RUSTDOC_FENCE.len()..];
+ let guards = &line[idx + RUSTDOC_FENCE_LENGTH..];
let is_rust = is_rust_fence(guards);
is_doctest = is_codeblock && is_rust;
continue;