diff --git a/src/parser/keyword.rs b/src/parser/keyword.rs index 858b59b..c78f899 100644 --- a/src/parser/keyword.rs +++ b/src/parser/keyword.rs @@ -9,6 +9,7 @@ use nom::character::complete::one_of; use nom::character::complete::space0; use nom::combinator::consumed; use nom::combinator::eof; +use nom::combinator::map; use nom::combinator::not; use nom::combinator::peek; use nom::combinator::recognize; @@ -22,7 +23,6 @@ use super::org_source::OrgSource; use super::util::get_consumed; use super::util::maybe_consume_trailing_whitespace_if_not_exiting; use crate::context::parser_with_context; -use crate::context::Matcher; use crate::context::RefContext; use crate::error::CustomError; use crate::error::MyError; @@ -152,12 +152,7 @@ fn affiliated_key<'b, 'g, 'r, 's>( input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { alt(( - recognize(tuple(( - parser_with_context!(dual_affiliated_key)(context), - tag("["), - optval, - tag("]"), - ))), + parser_with_context!(dual_affiliated_key)(context), parser_with_context!(plain_affiliated_key)(context), export_keyword, ))(input) @@ -169,7 +164,13 @@ fn plain_affiliated_key<'b, 'g, 'r, 's>( input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { for keyword in context.get_global_settings().element_affiliated_keywords { - let result = tag_no_case::<_, _, CustomError<_>>(*keyword)(input); + let result = map( + tuple(( + tag_no_case::<_, _, CustomError<_>>(*keyword), + peek(tag(":")), + )), + |(key, _)| key, + )(input); match result { Ok((remaining, ent)) => { return Ok((remaining, ent)); @@ -189,7 +190,13 @@ fn dual_affiliated_key<'b, 'g, 'r, 's>( input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { for keyword in context.get_global_settings().element_dual_keywords { - let result = tag_no_case::<_, _, CustomError<_>>(*keyword)(input); + let result = recognize(tuple(( + tag_no_case::<_, _, CustomError<_>>(*keyword), + tag("["), + optval, + tag("]"), + peek(tag(":")), + )))(input); match result { Ok((remaining, ent)) => { return Ok((remaining, ent));