diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 8ef88901f3c725ad050bf3ae792aa7de8e2a3dc5..998a180e63b2ad5f784d1953ba95e4853e3c3031 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -223,6 +223,7 @@ impl Markdown { } pub fn escape(s: &str) -> Cow { + // Valid to use bytes since multi-byte UTF-8 doesn't use ASCII chars. let count = s .bytes() .filter(|c| *c == b'\n' || c.is_ascii_punctuation()) diff --git a/crates/markdown/src/parser.rs b/crates/markdown/src/parser.rs index e5e584728942e40267c547bb3d0cf57826affbdc..debfe5245f547a6553789c029eba7edbc6e6cc5a 100644 --- a/crates/markdown/src/parser.rs +++ b/crates/markdown/src/parser.rs @@ -79,9 +79,10 @@ pub fn parse_markdown( let content_range = content_range.start + range.start..content_range.end + range.start; + // Valid to use bytes since multi-byte UTF-8 doesn't use ASCII chars. let line_count = text[content_range.clone()] - .chars() - .filter(|c| *c == '\n') + .bytes() + .filter(|c| *c == b'\n') .count(); let metadata = CodeBlockMetadata { content_range,