diff --git a/src/parse/incremental.rs b/src/parse/incremental.rs index a2ba502b8..663187909 100644 --- a/src/parse/incremental.rs +++ b/src/parse/incremental.rs @@ -364,7 +364,7 @@ mod tests { test("hey #myfriend", 4 .. 4, "\\", 0 .. 14); test("hey #myfriend", 4 .. 4, "\\", 3 .. 6); test("= foo\nbar\n - a\n - b", 6 .. 9, "", 0 .. 11); - test("= foo\n bar\n baz", 6 .. 8, "", 0 .. 15); + test("= foo\n bar\n baz", 6 .. 8, "", 0 .. 9); } #[test] diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 58b81521e..55f2fd492 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -161,6 +161,11 @@ fn markup(p: &mut Parser, mut at_start: bool) { }); } +/// Parse a single line of markup. +fn markup_line(p: &mut Parser) { + markup_indented(p, usize::MAX); +} + /// Parse markup that stays right of the given `column`. fn markup_indented(p: &mut Parser, column: usize) { p.eat_while(|t| match t { @@ -272,8 +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()) { - let column = p.column(p.prev_end()); - markup_indented(p, column); + markup_line(p); marker.end(p, NodeKind::Heading); } else { let text = p.get(current_start .. p.prev_end()).into(); diff --git a/tests/ref/structure/heading.png b/tests/ref/structure/heading.png index 09f3d7c70..693ae7637 100644 Binary files a/tests/ref/structure/heading.png and b/tests/ref/structure/heading.png differ diff --git a/tests/typ/structure/heading.typ b/tests/typ/structure/heading.typ index 2ae97aa80..f4ba5f33e 100644 --- a/tests/typ/structure/heading.typ +++ b/tests/typ/structure/heading.typ @@ -26,19 +26,15 @@ No = heading \= No heading --- -// While indented at least as much as the start, the heading continues. +// Blocks can continue the heading. + += [This +is +multiline. +] = This - is - indented. - -= This -is not. - -// Code blocks continue heading. -= A { - "B" -} + is not. --- // Test styling.