Skip to content

Commit

Permalink
fix: reject leading ., ) without prefix as item marker
Browse files Browse the repository at this point in the history
fix #5835
  • Loading branch information
xxchan committed Jul 17, 2023
1 parent d698bf4 commit f809481
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ impl ItemizedBlock {
// allowed.
for suffix in [". ", ") "] {
if let Some((prefix, _)) = trimmed.split_once(suffix) {
if prefix.len() <= 2 && prefix.chars().all(|c| char::is_ascii_digit(&c)) {
if (1..=2).contains(&prefix.len())
&& prefix.chars().all(|c| char::is_ascii_digit(&c))
{
return Some(prefix.len() + suffix.len());
}
}
Expand Down Expand Up @@ -2142,6 +2144,9 @@ fn main() {
// https://spec.commonmark.org/0.30 says: "A start number may not be negative":
"-1. Not a list item.",
"-1 Not a list item.",
// Marker without prefix are not recognized as item markers:
". Not a list item.",
") Not a list item.",
];
for line in test_inputs.iter() {
let maybe_block = ItemizedBlock::new(line);
Expand Down

0 comments on commit f809481

Please sign in to comment.