diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 4cfebd3ee..e1682adcc 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -357,6 +357,7 @@ impl Eval for NodeHeading { ctx.state.font.strong = true; self.contents.eval(ctx); + SynNode::Parbreak.eval(ctx); ctx.state = prev; } diff --git a/src/parse/mod.rs b/src/parse/mod.rs index d2408c7b0..96ef18d22 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -100,11 +100,10 @@ fn heading(p: &mut Parser, start: Pos) -> NodeHeading { let span = Span::new(start, p.pos()); let level = (count.min(5) as u8).span_with(span); if count > 5 { - p.diag(warning!(span, "section depth larger than 6 has no effect")); + p.diag(warning!(span, "section depth should be at most 6")); } // Parse the heading contents. - p.skip_white(); let mut contents = vec![]; while p.check(|t| !matches!(t, Token::Space(n) if n >= 1)) { if let Some(node) = node(p, false) { diff --git a/src/parse/tests.rs b/src/parse/tests.rs index e0712b367..054b2cd90 100644 --- a/src/parse/tests.rs +++ b/src/parse/tests.rs @@ -295,31 +295,33 @@ fn test_parse_comments() { #[test] fn test_parse_headings() { - t!("## Hello world!" => H![1, T("Hello"), S, T("world!")]); + t!("## Hello world!" => H![1, S, T("Hello"), S, T("world!")]); // Handle various whitespace usages. t!("####Simple" => H![3, T("Simple")]); - t!(" # Whitespace!" => S, H![0, T("Whitespace!")]); - t!(" /* TODO: Improve */ ## Analysis" => S, S, H!(1, T("Analysis"))); + t!(" # Whitespace!" => S, H![0, S, T("Whitespace!")]); + t!(" /* TODO: Improve */ ## Analysis" => S, S, H!(1, S, T("Analysis"))); + t!("# Heading \n ends" => H![0, S, T("Heading")], S, T("ends")); // Complex heading contents. t!("Some text [box][### Valuable facts]" => T("Some"), S, T("text"), S, - F!("box"; Tree![H!(2, T("Valuable"), S, T("facts"))]) + F!("box"; Tree![H!(2, S, T("Valuable"), S, T("facts"))]) ); - t!("### Grandiose stuff [box][Get it \n\n straight]" => H![2, - T("Grandiose"), S, T("stuff"), S, + t!("### Grandiose stuff [box][Get it \n\n straight]" => H![ + 2, + S, T("Grandiose"), S, T("stuff"), S, F!("box"; Tree![T("Get"), S, T("it"), P, T("straight")]) ]); - t!("###### Multiline \\ headings" => H![5, T("Multiline"), S, L, S, T("headings")]); + t!("###### Multiline \\ headings" => H![5, S, T("Multiline"), S, L, S, T("headings")]); // Things that should not become headings. t!("\\## Text" => T("#"), T("#"), S, T("Text")); - t!(" ###### # Text" => S, H!(5, T("#"), S, T("Text"))); + t!(" ###### # Text" => S, H![5, S, T("#"), S, T("Text")]); t!("I am #1" => T("I"), S, T("am"), S, T("#"), T("1")); t!("[box][\n] # hi" => F!("box"; Tree![S]), S, T("#"), S, T("hi")); // Depth warnings. - e!("########" => s(0, 8, "section depth larger than 6 has no effect")); + e!("########" => s(0, 8, "section depth should be at most 6")); } #[test]