Make the item tag exit matcher a lower class than all all others.
This is to allow for " :: " inside a description list item's tag if it is nested inside another object.
This commit is contained in:
parent
ab612f293f
commit
40f22034da
@ -108,7 +108,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
|
||||
&'r self,
|
||||
i: OrgSource<'s>,
|
||||
) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError<OrgSource<'s>>> {
|
||||
let mut current_class_filter = ExitClass::Gamma;
|
||||
let mut current_class_filter = ExitClass::Delta;
|
||||
for current_node in self.iter_context() {
|
||||
let context_element = current_node.get_data();
|
||||
match context_element {
|
||||
|
@ -1,16 +1,10 @@
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum ExitClass {
|
||||
/// Headlines and sections.
|
||||
Document = 1,
|
||||
|
||||
/// Elements who take priority over beta elements when matching.
|
||||
Alpha = 20,
|
||||
|
||||
/// Elements who cede priority to alpha elements when matching.
|
||||
Beta = 300,
|
||||
|
||||
/// Elements who cede priority to alpha and beta elements when matching.
|
||||
Gamma = 4000,
|
||||
Alpha = 2,
|
||||
Beta = 3,
|
||||
Gamma = 4,
|
||||
Delta = 5,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ExitClass {
|
||||
|
@ -152,11 +152,8 @@ pub fn plain_list_item<'b, 'g, 'r, 's>(
|
||||
|
||||
// TODO: parse checkbox
|
||||
|
||||
let (remaining, maybe_tag) = opt(tuple((
|
||||
space1,
|
||||
parser_with_context!(item_tag)(context),
|
||||
tag(" ::"),
|
||||
)))(remaining)?;
|
||||
let (remaining, maybe_tag) =
|
||||
opt(tuple((space1, parser_with_context!(item_tag)(context))))(remaining)?;
|
||||
let maybe_contentless_item: Res<OrgSource<'_>, OrgSource<'_>> =
|
||||
peek(recognize(tuple((many0(blank_line), eof))))(remaining);
|
||||
match maybe_contentless_item {
|
||||
@ -170,7 +167,7 @@ pub fn plain_list_item<'b, 'g, 'r, 's>(
|
||||
indentation: indent_level,
|
||||
bullet: bull.into(),
|
||||
tag: maybe_tag
|
||||
.map(|(_ws, item_tag, _divider)| item_tag)
|
||||
.map(|(_ws, item_tag)| item_tag)
|
||||
.unwrap_or(Vec::new()),
|
||||
children: Vec::new(),
|
||||
},
|
||||
@ -219,7 +216,7 @@ pub fn plain_list_item<'b, 'g, 'r, 's>(
|
||||
indentation: indent_level,
|
||||
bullet: bull.into(),
|
||||
tag: maybe_tag
|
||||
.map(|(_ws, item_tag, _divider)| item_tag)
|
||||
.map(|(_ws, item_tag)| item_tag)
|
||||
.unwrap_or(Vec::new()),
|
||||
children: children.into_iter().map(|(_start, item)| item).collect(),
|
||||
},
|
||||
@ -313,11 +310,18 @@ fn item_tag<'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::Gamma,
|
||||
exit_matcher: &item_tag_end,
|
||||
});
|
||||
let parser_context = context.with_additional_node(&parser_context);
|
||||
let contexts = [
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Gamma,
|
||||
exit_matcher: &item_tag_line_ending_end,
|
||||
}),
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Delta,
|
||||
exit_matcher: &item_tag_end,
|
||||
}),
|
||||
];
|
||||
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(
|
||||
// TODO: Should this be using a different set like the minimal set?
|
||||
@ -326,6 +330,7 @@ fn item_tag<'b, 'g, 'r, 's>(
|
||||
),
|
||||
|(children, _exit_contents)| !children.is_empty(),
|
||||
)(input)?;
|
||||
let (remaining, _) = tag(" ::")(remaining)?;
|
||||
Ok((remaining, children))
|
||||
}
|
||||
|
||||
@ -335,12 +340,19 @@ fn item_tag_end<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
recognize(alt((
|
||||
line_ending,
|
||||
tag(" :: "),
|
||||
recognize(tuple((tag(" ::"), alt((line_ending, eof))))),
|
||||
)))(input)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn item_tag_line_ending_end<'b, 'g, 'r, 's>(
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
line_ending(input)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn item_tag_post_gap<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user