Allow text markup at the start of a radio target.
This commit is contained in:
@@ -103,11 +103,15 @@ pub(crate) fn radio_target<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, RadioTarget<'s>> {
|
||||
let (remaining, _opening) = tag("<<<")(input)?;
|
||||
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Gamma,
|
||||
exit_matcher: &radio_target_end,
|
||||
});
|
||||
let parser_context = context.with_additional_node(&parser_context);
|
||||
let contexts = [
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Gamma,
|
||||
exit_matcher: &radio_target_end,
|
||||
}),
|
||||
ContextElement::StartRadioTarget(remaining),
|
||||
];
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
|
||||
let (remaining, (raw_value, children)) = consumed(verify(
|
||||
map(
|
||||
|
||||
@@ -283,7 +283,7 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn pre<'b, 'g, 'r, 's>(
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, ()> {
|
||||
if start_of_line(input).is_ok() {
|
||||
@@ -292,6 +292,16 @@ fn pre<'b, 'g, 'r, 's>(
|
||||
if preceded_by_whitespace(true)(input).is_ok() {
|
||||
return Ok((input, ()));
|
||||
}
|
||||
let radio_target_start = context
|
||||
.iter()
|
||||
.find_map(|c| match c {
|
||||
ContextElement::StartRadioTarget(text) => Some(text),
|
||||
_ => None,
|
||||
})
|
||||
.map(|text| text.get_byte_offset());
|
||||
if Some(input.get_byte_offset()) == radio_target_start {
|
||||
return Ok((input, ()));
|
||||
}
|
||||
let preceding_character = input.get_preceding_character();
|
||||
match preceding_character {
|
||||
// If None, we are at the start of the file which is technically the beginning of a line.
|
||||
|
||||
Reference in New Issue
Block a user