diff --git a/src/context/context.rs b/src/context/context.rs index 0baa2e8b..a485cdf7 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -108,7 +108,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> { &'r self, i: OrgSource<'s>, ) -> IResult, OrgSource<'s>, CustomError>> { - 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 { diff --git a/src/context/exiting.rs b/src/context/exiting.rs index 6f8c359d..c989a335 100644 --- a/src/context/exiting.rs +++ b/src/context/exiting.rs @@ -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 { diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 9dbc117a..f74de757 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -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<'_>> = 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, Vec>> { - 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>> { 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>> { + 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>,