Support text markup at the start of a regular link description.
rust-build Build rust-build has succeeded Details
rust-test Build rust-test has succeeded Details
rust-foreign-document-test Build rust-foreign-document-test has failed Details

This commit is contained in:
Tom Alexander 2023-10-09 14:02:27 -04:00
parent adc5a383c3
commit 840dc0a750
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 14 additions and 10 deletions

View File

@ -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)]

View File

@ -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]);

View File

@ -397,11 +397,15 @@ fn description<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Vec<Object<'s>>> {
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),

View File

@ -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());