Skip to content

Commit f809481

Browse files
committed
fix: reject leading ., ) without prefix as item marker
fix rust-lang#5835
1 parent d698bf4 commit f809481

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/comment.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,9 @@ impl ItemizedBlock {
484484
// allowed.
485485
for suffix in [". ", ") "] {
486486
if let Some((prefix, _)) = trimmed.split_once(suffix) {
487-
if prefix.len() <= 2 && prefix.chars().all(|c| char::is_ascii_digit(&c)) {
487+
if (1..=2).contains(&prefix.len())
488+
&& prefix.chars().all(|c| char::is_ascii_digit(&c))
489+
{
488490
return Some(prefix.len() + suffix.len());
489491
}
490492
}
@@ -2142,6 +2144,9 @@ fn main() {
21422144
// https://spec.commonmark.org/0.30 says: "A start number may not be negative":
21432145
"-1. Not a list item.",
21442146
"-1 Not a list item.",
2147+
// Marker without prefix are not recognized as item markers:
2148+
". Not a list item.",
2149+
") Not a list item.",
21452150
];
21462151
for line in test_inputs.iter() {
21472152
let maybe_block = ItemizedBlock::new(line);

0 commit comments

Comments
 (0)