Skip to content

Commit

Permalink
fix: reject leading ., ) without prefix as item marker
Browse files Browse the repository at this point in the history
  • Loading branch information
xxchan authored and ytmimi committed Aug 29, 2023
1 parent df2471b commit 03d752d
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 @@ -482,7 +482,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 @@ -2126,6 +2128,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 03d752d

Please sign in to comment.