Fix handling of text markup at the start/end of regular link descriptions and radio targets.
This commit is contained in:
@@ -2,15 +2,17 @@ use nom::branch::alt;
|
||||
use nom::bytes::complete::tag;
|
||||
use nom::character::complete::line_ending;
|
||||
use nom::character::complete::space0;
|
||||
use nom::combinator::all_consuming;
|
||||
use nom::combinator::consumed;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::map_parser;
|
||||
use nom::combinator::verify;
|
||||
use nom::multi::many_till;
|
||||
use nom::multi::many1;
|
||||
|
||||
use super::object_parser::minimal_set_object;
|
||||
use super::org_source::OrgSource;
|
||||
use super::util::exit_matcher_parser;
|
||||
use super::util::confine_context;
|
||||
use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting;
|
||||
use super::util::text_until_exit;
|
||||
use crate::context::parser_with_context;
|
||||
use crate::context::ContextElement;
|
||||
use crate::context::ExitClass;
|
||||
@@ -103,25 +105,20 @@ pub(crate) fn radio_target<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, RadioTarget<'s>> {
|
||||
let (remaining, _opening) = tag("<<<")(input)?;
|
||||
let contexts = [
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Gamma,
|
||||
exit_matcher: &radio_target_end,
|
||||
}),
|
||||
ContextElement::StartTextSection(remaining),
|
||||
];
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Gamma,
|
||||
exit_matcher: &radio_target_end,
|
||||
});
|
||||
let parser_context = context.with_additional_node(&parser_context);
|
||||
|
||||
let (remaining, (raw_value, children)) = consumed(verify(
|
||||
map(
|
||||
many_till(
|
||||
parser_with_context!(minimal_set_object)(&parser_context),
|
||||
parser_with_context!(exit_matcher_parser)(&parser_context),
|
||||
),
|
||||
|(children, _)| children,
|
||||
let (remaining, (raw_value, children)) = consumed(map_parser(
|
||||
verify(
|
||||
parser_with_context!(text_until_exit)(&parser_context),
|
||||
|text| text.len() > 0,
|
||||
),
|
||||
|children: &Vec<_>| !children.is_empty(),
|
||||
confine_context(|i| {
|
||||
all_consuming(many1(parser_with_context!(minimal_set_object)(context)))(i)
|
||||
}),
|
||||
))(remaining)?;
|
||||
|
||||
let (remaining, _closing) = tag(">>>")(remaining)?;
|
||||
|
||||
Reference in New Issue
Block a user