From d0410391cc260bdcc1f6ff4ad962c1494ecab046 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 19 Apr 2023 19:28:21 -0400 Subject: [PATCH] Drop blank lines after property drawer instead of owning them. --- src/parser/document.rs | 3 ++- toy_language.txt | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/parser/document.rs b/src/parser/document.rs index ddaa283e..e57710e7 100644 --- a/src/parser/document.rs +++ b/src/parser/document.rs @@ -132,6 +132,7 @@ fn zeroth_section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s &without_consuming_whitespace_context, )), parser_with_context!(property_drawer)(&without_consuming_whitespace_context), + many0(blank_line), )))(input)?; let (remaining, (mut children, _exit_contents)) = verify( @@ -141,7 +142,7 @@ fn zeroth_section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s }, )(remaining)?; - comment_and_property_drawer_element.map(|(comment, property_drawer)| { + comment_and_property_drawer_element.map(|(comment, property_drawer, _ws)| { children.insert(0, Element::PropertyDrawer(property_drawer)); comment .map(Element::Comment) diff --git a/toy_language.txt b/toy_language.txt index e432ad0b..25380541 100644 --- a/toy_language.txt +++ b/toy_language.txt @@ -3,10 +3,23 @@ # Blank lines and comments can come before property drawers in the zeroth section +:PROPERTIES: +:FOO: bar +:END: +* Spaces turn property drawers into regular drawers :PROPERTIES: :FOO: bar :END: +* Comments turn property drawers into regular drawers +# Comment +:PROPERTIES: +:FOO: bar +:END: +* Baseline +:PROPERTIES: +:FOO: bar +:END: