From 15ef72cca427c63b2e545d645b49ff27aecffad6 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 4 May 2022 23:33:40 +0200 Subject: Fix empty heading --- src/parse/mod.rs | 2 +- tests/ref/structure/heading.png | Bin 22641 -> 24525 bytes tests/ref/structure/list.png | Bin 20169 -> 20656 bytes tests/typ/structure/heading.typ | 6 ++++++ tests/typ/structure/list.typ | 4 ++++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/parse/mod.rs b/src/parse/mod.rs index b473c9af..86d18cba 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -285,7 +285,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()); + p.eat_while(|kind| kind == &NodeKind::Space(0)); markup_line(p); marker.end(p, NodeKind::Heading); } else { diff --git a/tests/ref/structure/heading.png b/tests/ref/structure/heading.png index 3e12b2cf..7ad228ab 100644 Binary files a/tests/ref/structure/heading.png and b/tests/ref/structure/heading.png differ diff --git a/tests/ref/structure/list.png b/tests/ref/structure/list.png index 7a60e1e5..5d0f03c0 100644 Binary files a/tests/ref/structure/list.png and b/tests/ref/structure/list.png differ diff --git a/tests/typ/structure/heading.typ b/tests/typ/structure/heading.typ index de95c35b..496181bd 100644 --- a/tests/typ/structure/heading.typ +++ b/tests/typ/structure/heading.typ @@ -1,5 +1,11 @@ // Test headings. +--- +#show node: heading as text(blue, node.body) + += +No heading + --- // Different number of equals signs. diff --git a/tests/typ/structure/list.typ b/tests/typ/structure/list.typ index 77e153c7..5c410a3f 100644 --- a/tests/typ/structure/list.typ +++ b/tests/typ/structure/list.typ @@ -1,5 +1,9 @@ // Test lists. +--- +- +No list + --- _Shopping list_ #list(attached: true)[Apples][Potatoes][Juice] -- cgit v1.2.3