diff --git a/src/parser/entity.rs b/src/parser/entity.rs index 4fcb8cf..53a0b09 100644 --- a/src/parser/entity.rs +++ b/src/parser/entity.rs @@ -1,10 +1,10 @@ use nom::branch::alt; use nom::bytes::complete::tag; -use nom::bytes::complete::tag_no_case; use nom::character::complete::satisfy; use nom::combinator::eof; use nom::combinator::peek; use nom::combinator::recognize; +use nom::sequence::tuple; use super::org_source::OrgSource; use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; @@ -439,7 +439,7 @@ pub(crate) fn entity<'b, 'g, 'r, 's>( ) -> Res, Entity<'s>> { let (remaining, _) = tag("\\")(input)?; let (remaining, entity_name) = name(context, remaining)?; - let (remaining, _) = alt((tag("{}"), peek(recognize(entity_end))))(remaining)?; + let (remaining, _trailing_whitespace) = maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?; @@ -460,9 +460,12 @@ fn name<'b, 'g, 'r, 's>( ) -> Res, OrgSource<'s>> { // TODO: This should be defined by org-entities and optionally org-entities-user for entity in ORG_ENTITIES { - let result = tag_no_case::<_, _, CustomError<_>>(entity)(input); + let result = tuple(( + tag::<_, _, CustomError<_>>(entity), + alt((tag("{}"), peek(recognize(entity_end)))), + ))(input); match result { - Ok((remaining, ent)) => { + Ok((remaining, (ent, _))) => { return Ok((remaining, ent)); } Err(_) => {}