Skip to content

Commit 4166b65

Browse files
authored
Merge pull request #723 from taminomara/fix-crash-in-md
Fix crash in markdown parser
2 parents 53b6439 + 1781485 commit 4166b65

File tree

1 file changed

+10
-2
lines changed
  • crates/emmylua_parser_desc/src

1 file changed

+10
-2
lines changed

crates/emmylua_parser_desc/src/md.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ impl MdParser {
638638
}
639639

640640
let text = reader.tail_text();
641-
if text.len() >= 4 && is_blank(&text[..4]) {
641+
if text.len() >= 4 && text.is_char_boundary(4) && is_blank(&text[..4]) {
642642
// List marker followed by a space, then 4 more spaces
643643
// is parsed as a list marker followed by a space,
644644
// then code block.
@@ -1522,6 +1522,10 @@ mod tests {
15221522
---
15231523
--- Continuation 2
15241524
---
1525+
--- -测试 <- not a list
1526+
---
1527+
--- - 测试 <- list
1528+
---
15251529
--- -
15261530
--- List that starts with empty string
15271531
---
@@ -1647,7 +1651,11 @@ mod tests {
16471651
---
16481652
--- <CodeBlock>Continuation 2</CodeBlock>
16491653
---
1650-
--- </Scope></Scope><Scope><Markup>-</Markup>
1654+
--- </Scope></Scope>-测试 <- not a list
1655+
---
1656+
--- <Scope><Markup>-</Markup> 测试 <- list
1657+
---
1658+
--- </Scope><Scope><Markup>-</Markup>
16511659
--- List that starts with empty string
16521660
---
16531661
--- </Scope> Not list

0 commit comments

Comments
 (0)