Do not use the plain text parser for property drawers.

This additional exit condition was causing property drawers to parse incorrectly.
This commit is contained in:
Tom Alexander 2023-08-29 22:03:20 -04:00
parent f170a557ed
commit 6f2d90162b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 17 additions and 5 deletions

View File

@ -0,0 +1,7 @@
** foo
:PROPERTIES:
:DESCRIPTION: lorem
:ALT_TITLE: ipsum
:END:
bar

View File

@ -2,13 +2,14 @@ use nom::branch::alt;
use nom::bytes::complete::is_not;
use nom::bytes::complete::tag;
use nom::bytes::complete::tag_no_case;
use nom::character::complete::anychar;
use nom::character::complete::line_ending;
use nom::character::complete::space0;
use nom::character::complete::space1;
use nom::combinator::eof;
use nom::combinator::map;
use nom::combinator::opt;
use nom::combinator::recognize;
use nom::combinator::verify;
use nom::multi::many_till;
use nom::sequence::tuple;
@ -23,7 +24,6 @@ use crate::parser::greater_element::PropertyDrawer;
use crate::parser::parser_context::ContextElement;
use crate::parser::parser_context::ExitMatcherNode;
use crate::parser::parser_with_context::parser_with_context;
use crate::parser::plain_text::plain_text;
use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed;
use crate::parser::util::immediate_in_section;
@ -147,11 +147,16 @@ fn node_property_name<'r, 's>(
}));
let (remaining, name) = recognize(tuple((
map(parser_with_context!(plain_text)(&parser_context), |pt| {
pt.source
}),
verify(
many_till(
anychar,
parser_with_context!(exit_matcher_parser)(&parser_context),
),
|(children, _exit_contents)| !children.is_empty(),
),
opt(tag("+")),
)))(input)?;
Ok((remaining, name))
}