diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 55f2fd492..0e68c0d17 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -277,6 +277,7 @@ fn heading(p: &mut Parser, at_start: bool) { while p.eat_if(&NodeKind::Eq) {} if at_start && p.peek().map_or(true, |kind| kind.is_space()) { + p.eat_while(|kind| kind.is_space()); markup_line(p); marker.end(p, NodeKind::Heading); } else { @@ -291,8 +292,8 @@ fn list_node(p: &mut Parser, at_start: bool) { let text: EcoString = p.peek_src().into(); p.eat_assert(&NodeKind::Minus); - if at_start && p.peek().map_or(true, |kind| kind.is_space()) { - let column = p.column(p.prev_end()); + let column = p.column(p.prev_end()); + if at_start && p.eat_if(&NodeKind::Space(0)) && !p.eof() { markup_indented(p, column); marker.end(p, NodeKind::List); } else { @@ -306,8 +307,8 @@ fn enum_node(p: &mut Parser, at_start: bool) { let text: EcoString = p.peek_src().into(); p.eat(); - if at_start && p.peek().map_or(true, |kind| kind.is_space()) { - let column = p.column(p.prev_end()); + let column = p.column(p.prev_end()); + if at_start && p.eat_if(&NodeKind::Space(0)) && !p.eof() { markup_indented(p, column); marker.end(p, NodeKind::Enum); } else { diff --git a/tests/ref/structure/enum.png b/tests/ref/structure/enum.png index ecd1cf53f..9aec92134 100644 Binary files a/tests/ref/structure/enum.png and b/tests/ref/structure/enum.png differ diff --git a/tests/ref/structure/list.png b/tests/ref/structure/list.png index e8a38616e..ac90f4b20 100644 Binary files a/tests/ref/structure/list.png and b/tests/ref/structure/list.png differ diff --git a/tests/typ/structure/enum.typ b/tests/typ/structure/enum.typ index 24c28147b..31eb0d62b 100644 --- a/tests/typ/structure/enum.typ +++ b/tests/typ/structure/enum.typ @@ -46,6 +46,10 @@ [Red], [Green], [Blue], ) +--- +// Lone dot is not a list. +. + --- // Error: 18-20 invalid pattern #set enum(label: "") diff --git a/tests/typ/structure/list.typ b/tests/typ/structure/list.typ index 67be16281..a01a90dde 100644 --- a/tests/typ/structure/list.typ +++ b/tests/typ/structure/list.typ @@ -49,3 +49,8 @@ paragraphs. // This doesn't work because of mixed tabs and spaces. - A with 2 spaces - B with 2 tabs + +--- +#set list(label: [-]) +- Bare hyphen +- is not a list