From abafb39041d47f1fe4281c60cb4e3e40db2181d1 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 26 Sep 2022 16:25:40 +0200 Subject: Fix bad list interaction Fixes #87 --- src/model/content.rs | 5 +++++ src/parse/parser.rs | 4 ++-- tests/ref/structure/enum.png | Bin 29125 -> 27743 bytes tests/typ/structure/enum.typ | 15 ++++++++------- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/model/content.rs b/src/model/content.rs index ae074b50..7828a3cd 100644 --- a/src/model/content.rs +++ b/src/model/content.rs @@ -413,6 +413,11 @@ impl<'a> Builder<'a> { self.interrupt(Interruption::List, styles, false)?; + if let Content::Item(_) = content { + self.list.accept(content, styles); + return Ok(()); + } + if self.par.accept(content, styles) { return Ok(()); } diff --git a/src/parse/parser.rs b/src/parse/parser.rs index 90b6e610..f8ea9614 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -454,8 +454,8 @@ impl Marker { /// Wrap all children after the marker (excluding trailing trivia) in a node /// with the given `kind`. pub fn end(self, p: &mut Parser, kind: NodeKind) { - let until = p.trivia_start(); - let children = p.children.drain(self.0 .. until.0).collect(); + let until = p.trivia_start().0.max(self.0); + let children = p.children.drain(self.0 .. until).collect(); p.children .insert(self.0, InnerNode::with_children(kind, children).into()); } diff --git a/tests/ref/structure/enum.png b/tests/ref/structure/enum.png index 20bb08d4..f58a6c85 100644 Binary files a/tests/ref/structure/enum.png and b/tests/ref/structure/enum.png differ diff --git a/tests/typ/structure/enum.typ b/tests/typ/structure/enum.typ index eb1d9a9d..4ff13ff4 100644 --- a/tests/typ/structure/enum.typ +++ b/tests/typ/structure/enum.typ @@ -5,14 +5,9 @@ --- 1. First. - 2. Second. + 2. Indented -1. Back to first. - ---- -2. Second -1. First - + Indented ++ Second --- // Test automatic numbering in summed content. @@ -35,6 +30,12 @@ + A + B +--- +// Mix of different lists +- List ++ Enum +/ Desc: List + --- // Test label closure. #enum( -- cgit v1.2.3