Support text markup at the start of a regular link description.
This commit is contained in:
parent
adc5a383c3
commit
840dc0a750
@ -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.
|
/// 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>),
|
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.
|
/// 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.
|
||||||
StartRadioTarget(OrgSource<'s>),
|
StartTextSection(OrgSource<'s>),
|
||||||
|
|
||||||
/// This is just here to use the 's lifetime until I'm sure we can eliminate it from ContextElement.
|
/// This is just here to use the 's lifetime until I'm sure we can eliminate it from ContextElement.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -108,7 +108,7 @@ pub(crate) fn radio_target<'b, 'g, 'r, 's>(
|
|||||||
class: ExitClass::Gamma,
|
class: ExitClass::Gamma,
|
||||||
exit_matcher: &radio_target_end,
|
exit_matcher: &radio_target_end,
|
||||||
}),
|
}),
|
||||||
ContextElement::StartRadioTarget(remaining),
|
ContextElement::StartTextSection(remaining),
|
||||||
];
|
];
|
||||||
let parser_context = context.with_additional_node(&contexts[0]);
|
let parser_context = context.with_additional_node(&contexts[0]);
|
||||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||||
|
@ -397,11 +397,15 @@ fn description<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Vec<Object<'s>>> {
|
) -> Res<OrgSource<'s>, Vec<Object<'s>>> {
|
||||||
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
|
let contexts = [
|
||||||
|
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
class: ExitClass::Beta,
|
class: ExitClass::Beta,
|
||||||
exit_matcher: &description_end,
|
exit_matcher: &description_end,
|
||||||
});
|
}),
|
||||||
let parser_context = context.with_additional_node(&parser_context);
|
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(
|
let (remaining, (children, _exit_contents)) = verify(
|
||||||
many_till(
|
many_till(
|
||||||
parser_with_context!(regular_link_description_set_object)(&parser_context),
|
parser_with_context!(regular_link_description_set_object)(&parser_context),
|
||||||
|
@ -295,7 +295,7 @@ fn pre<'b, 'g, 'r, 's>(
|
|||||||
let radio_target_start = context
|
let radio_target_start = context
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|c| match c {
|
.find_map(|c| match c {
|
||||||
ContextElement::StartRadioTarget(text) => Some(text),
|
ContextElement::StartTextSection(text) => Some(text),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.map(|text| text.get_byte_offset());
|
.map(|text| text.get_byte_offset());
|
||||||
|
Loading…
Reference in New Issue
Block a user