Skip to content

Commit 03d752d

Browse files
xxchanytmimi
authored andcommitted
fix: reject leading ., ) without prefix as item marker
fix rust-lang#5835
1 parent df2471b commit 03d752d

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
@@ -482,7 +482,9 @@ impl ItemizedBlock {
482482
// allowed.
483483
for suffix in [". ", ") "] {
484484
if let Some((prefix, _)) = trimmed.split_once(suffix) {
485-
if prefix.len() <= 2 && prefix.chars().all(|c| char::is_ascii_digit(&c)) {
485+
if (1..=2).contains(&prefix.len())
486+
&& prefix.chars().all(|c| char::is_ascii_digit(&c))
487+
{
486488
return Some(prefix.len() + suffix.len());
487489
}
488490
}
@@ -2126,6 +2128,9 @@ fn main() {
21262128
// https://spec.commonmark.org/0.30 says: "A start number may not be negative":
21272129
"-1. Not a list item.",
21282130
"-1 Not a list item.",
2131+
// Marker without prefix are not recognized as item markers:
2132+
". Not a list item.",
2133+
") Not a list item.",
21292134
];
21302135
for line in test_inputs.iter() {
21312136
let maybe_block = ItemizedBlock::new(line);

0 commit comments

Comments
 (0)