diff --git a/org_mode_samples/greater_element/plain_list/description_list_object_key.org b/org_mode_samples/greater_element/plain_list/description_list_object_key.org new file mode 100644 index 0000000..fcf945a --- /dev/null +++ b/org_mode_samples/greater_element/plain_list/description_list_object_key.org @@ -0,0 +1 @@ +- {{{foo(bar)}}} :: baz diff --git a/src/parser/org_macro.rs b/src/parser/org_macro.rs index 1900f4a..65a86c4 100644 --- a/src/parser/org_macro.rs +++ b/src/parser/org_macro.rs @@ -1,6 +1,5 @@ use nom::bytes::complete::tag; use nom::character::complete::anychar; -use nom::character::complete::space0; use nom::combinator::not; use nom::combinator::opt; use nom::combinator::peek; @@ -9,6 +8,7 @@ use nom::multi::many0; use nom::multi::separated_list0; use super::org_source::OrgSource; +use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; use super::Context; use crate::error::CustomError; use crate::error::Res; @@ -26,7 +26,8 @@ pub fn org_macro<'r, 's>( let (remaining, macro_name) = org_macro_name(context, remaining)?; let (remaining, macro_args) = opt(parser_with_context!(org_macro_args)(context))(remaining)?; let (remaining, _) = tag("}}}")(remaining)?; - let (remaining, _trailing_whitespace) = space0(remaining)?; + let (remaining, _trailing_whitespace) = + maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?; let source = get_consumed(input, remaining); Ok(( diff --git a/src/parser/util.rs b/src/parser/util.rs index 484a41d..e59eadd 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -68,6 +68,18 @@ pub fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res( + context: Context<'r, 's>, + input: OrgSource<'s>, +) -> Res, Option>> { + if exit_matcher_parser(context, input).is_err() { + opt(space0)(input) + } else { + Ok((input, None)) + } +} + #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] pub fn maybe_consume_trailing_whitespace_if_not_exiting<'r, 's>( context: Context<'r, 's>,