diff --git a/src/context/context.rs b/src/context/context.rs index 138338f8..6787273d 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -33,10 +33,10 @@ pub(crate) enum ContextElement<'r, 's> { /// The value stored is the start of the element after the affiliated keywords. In this way, we can ensure that we do not exit an element immediately after the affiliated keyword had been consumed. HasAffiliatedKeyword(HasAffiliatedKeywordInner<'r, 's>), - /// Indicate the position that we started parsing a radio target. + /// Indicate the position that we started parsing a text section. /// - /// This value is stored because "<<<" is not a valid prefix for text markup UNLESS it is starting a radio target. - StartRadioTarget(OrgSource<'s>), + /// This value is stored because "<<<" is not a valid prefix for text markup UNLESS it is starting a radio target. Likewise "[" is not a valid prefix for text markup UNLESS it is the start of a regular link description. + StartTextSection(OrgSource<'s>), /// This is just here to use the 's lifetime until I'm sure we can eliminate it from ContextElement. #[allow(dead_code)] diff --git a/src/parser/radio_link.rs b/src/parser/radio_link.rs index 15eb6cd7..c25ec3cb 100644 --- a/src/parser/radio_link.rs +++ b/src/parser/radio_link.rs @@ -108,7 +108,7 @@ pub(crate) fn radio_target<'b, 'g, 'r, 's>( class: ExitClass::Gamma, exit_matcher: &radio_target_end, }), - ContextElement::StartRadioTarget(remaining), + ContextElement::StartTextSection(remaining), ]; let parser_context = context.with_additional_node(&contexts[0]); let parser_context = parser_context.with_additional_node(&contexts[1]); diff --git a/src/parser/regular_link.rs b/src/parser/regular_link.rs index 199829c9..ce9ce374 100644 --- a/src/parser/regular_link.rs +++ b/src/parser/regular_link.rs @@ -397,11 +397,15 @@ fn description<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { - let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { - class: ExitClass::Beta, - exit_matcher: &description_end, - }); - let parser_context = context.with_additional_node(&parser_context); + let contexts = [ + ContextElement::ExitMatcherNode(ExitMatcherNode { + class: ExitClass::Beta, + exit_matcher: &description_end, + }), + ContextElement::StartTextSection(input), + ]; + let parser_context = context.with_additional_node(&contexts[0]); + let parser_context = parser_context.with_additional_node(&contexts[1]); let (remaining, (children, _exit_contents)) = verify( many_till( parser_with_context!(regular_link_description_set_object)(&parser_context), diff --git a/src/parser/text_markup.rs b/src/parser/text_markup.rs index d666633d..7bf7bf12 100644 --- a/src/parser/text_markup.rs +++ b/src/parser/text_markup.rs @@ -295,7 +295,7 @@ fn pre<'b, 'g, 'r, 's>( let radio_target_start = context .iter() .find_map(|c| match c { - ContextElement::StartRadioTarget(text) => Some(text), + ContextElement::StartTextSection(text) => Some(text), _ => None, }) .map(|text| text.get_byte_offset());