Revert unnecessary "fix handling of unicode when counting codeblock lines" + document (#30368)
After merging #30364 I realized why it was unnecessary to fix the code, and was more efficient before. UTF-8 does not use the standard 0-127 ASCII range for multi-byte chars. So this reverts that change and documents why the code is valid. Release Notes: - N/A
This commit is contained in:
parent
023a60806a
commit
30f3efe697
2 changed files with 4 additions and 2 deletions
|
@ -223,6 +223,7 @@ impl Markdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn escape(s: &str) -> Cow<str> {
|
pub fn escape(s: &str) -> Cow<str> {
|
||||||
|
// Valid to use bytes since multi-byte UTF-8 doesn't use ASCII chars.
|
||||||
let count = s
|
let count = s
|
||||||
.bytes()
|
.bytes()
|
||||||
.filter(|c| *c == b'\n' || c.is_ascii_punctuation())
|
.filter(|c| *c == b'\n' || c.is_ascii_punctuation())
|
||||||
|
|
|
@ -79,9 +79,10 @@ pub fn parse_markdown(
|
||||||
let content_range =
|
let content_range =
|
||||||
content_range.start + range.start..content_range.end + range.start;
|
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()]
|
let line_count = text[content_range.clone()]
|
||||||
.chars()
|
.bytes()
|
||||||
.filter(|c| *c == '\n')
|
.filter(|c| *c == b'\n')
|
||||||
.count();
|
.count();
|
||||||
let metadata = CodeBlockMetadata {
|
let metadata = CodeBlockMetadata {
|
||||||
content_range,
|
content_range,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue