From bf1a281c29623a6695fc493c1e23569594a09f91 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 9 Oct 2023 18:23:13 -0400 Subject: [PATCH] Footnote reference description is in a confined context. --- src/parser/footnote_reference.rs | 45 +++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/parser/footnote_reference.rs b/src/parser/footnote_reference.rs index 1793156..7e4e2c6 100644 --- a/src/parser/footnote_reference.rs +++ b/src/parser/footnote_reference.rs @@ -1,24 +1,29 @@ use nom::branch::alt; use nom::bytes::complete::tag; use nom::bytes::complete::tag_no_case; +use nom::combinator::all_consuming; +use nom::combinator::map_parser; use nom::combinator::verify; -use nom::multi::many_till; +use nom::multi::many1; use super::org_source::BracketDepth; use super::org_source::OrgSource; +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::Context; use crate::context::ContextElement; use crate::context::ContextMatcher; use crate::context::ExitClass; use crate::context::ExitMatcherNode; +use crate::context::List; use crate::context::RefContext; use crate::error::CustomError; use crate::error::MyError; use crate::error::Res; use crate::parser::footnote_definition::label; use crate::parser::object_parser::standard_set_object; -use crate::parser::util::exit_matcher_parser; use crate::parser::util::get_consumed; use crate::types::FootnoteReference; @@ -52,13 +57,21 @@ fn anonymous_footnote<'b, 'g, 'r, 's>( exit_matcher: &exit_with_depth, }); let parser_context = context.with_additional_node(&parser_context); - let (remaining, (children, _exit_contents)) = verify( - many_till( - parser_with_context!(standard_set_object)(&parser_context), - parser_with_context!(exit_matcher_parser)(&parser_context), + let initial_context = ContextElement::document_context(); + let initial_context = Context::new(context.get_global_settings(), List::new(&initial_context)); + + let (remaining, children) = map_parser( + verify( + parser_with_context!(text_until_exit)(&parser_context), + |text| text.len() > 0, ), - |(children, _exit_contents)| !children.is_empty(), + confine_context(|i| { + all_consuming(many1(parser_with_context!(standard_set_object)( + &initial_context, + )))(i) + }), )(remaining)?; + let (remaining, _) = tag("]")(remaining)?; let (remaining, _trailing_whitespace) = @@ -91,13 +104,21 @@ fn inline_footnote<'b, 'g, 'r, 's>( exit_matcher: &exit_with_depth, }); let parser_context = context.with_additional_node(&parser_context); - let (remaining, (children, _exit_contents)) = verify( - many_till( - parser_with_context!(standard_set_object)(&parser_context), - parser_with_context!(exit_matcher_parser)(&parser_context), + let initial_context = ContextElement::document_context(); + let initial_context = Context::new(context.get_global_settings(), List::new(&initial_context)); + + let (remaining, children) = map_parser( + verify( + parser_with_context!(text_until_exit)(&parser_context), + |text| text.len() > 0, ), - |(children, _exit_contents)| !children.is_empty(), + confine_context(|i| { + all_consuming(many1(parser_with_context!(standard_set_object)( + &initial_context, + )))(i) + }), )(remaining)?; + let (remaining, _) = tag("]")(remaining)?; let (remaining, _trailing_whitespace) =