Footnote reference description is in a confined context.

This commit is contained in:
Tom Alexander 2023-10-09 18:23:13 -04:00
parent df4daa0e16
commit bf1a281c29
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 33 additions and 12 deletions

View File

@ -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) =