summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parse/mod.rs9
-rw-r--r--tests/ref/structure/enum.pngbin26118 -> 25685 bytes
-rw-r--r--tests/ref/structure/list.pngbin21285 -> 22839 bytes
-rw-r--r--tests/typ/structure/enum.typ4
-rw-r--r--tests/typ/structure/list.typ5
5 files changed, 14 insertions, 4 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index 55f2fd49..0e68c0d1 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 ecd1cf53..9aec9213 100644
--- a/tests/ref/structure/enum.png
+++ b/tests/ref/structure/enum.png
Binary files differ
diff --git a/tests/ref/structure/list.png b/tests/ref/structure/list.png
index e8a38616..ac90f4b2 100644
--- a/tests/ref/structure/list.png
+++ b/tests/ref/structure/list.png
Binary files differ
diff --git a/tests/typ/structure/enum.typ b/tests/typ/structure/enum.typ
index 24c28147..31eb0d62 100644
--- a/tests/typ/structure/enum.typ
+++ b/tests/typ/structure/enum.typ
@@ -47,6 +47,10 @@
)
---
+// 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 67be1628..a01a90dd 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