diff --git a/src/parser/util.rs b/src/parser/util.rs index 6625b865..c9314c1d 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -8,6 +8,7 @@ use nom::combinator::not; use nom::combinator::opt; use nom::combinator::peek; use nom::combinator::recognize; +use nom::combinator::verify; use nom::multi::many0; use nom::multi::many_till; use nom::sequence::tuple; @@ -91,11 +92,15 @@ pub fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { - if exit_matcher_parser(context, input).is_err() { - opt(space0)(input) - } else { - Ok((input, None)) - } + // We have to check exit matcher after each character because description list tags need to end with a space unconsumed (" ::"). + let (remaining, _) = many_till( + verify(anychar, |c| *c == ' '), + alt(( + peek(recognize(verify(anychar, |c| *c != ' '))), + parser_with_context!(exit_matcher_parser)(context), + )), + )(input)?; + Ok((remaining, None)) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]