Create a new context tree when calling into confine_context.

The parent exit matchers were causing an issue.
This commit is contained in:
Tom Alexander 2023-10-09 17:32:37 -04:00
parent 13b95cd0a1
commit 5cd34ba3a2
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 15 additions and 2 deletions

View File

@ -0,0 +1,2 @@
# This test causes problems with regular links if we do not create a new ContextTree when calling into confine_context.
- foo [[info:bar][baz]] lorem

View File

@ -14,9 +14,11 @@ 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::ExitClass;
use crate::context::ExitMatcherNode;
use crate::context::List;
use crate::context::RefContext;
use crate::error::CustomError;
use crate::error::MyError;
@ -110,6 +112,8 @@ pub(crate) fn radio_target<'b, 'g, 'r, 's>(
exit_matcher: &radio_target_end,
});
let parser_context = context.with_additional_node(&parser_context);
let initial_context = ContextElement::document_context();
let initial_context = Context::new(context.get_global_settings(), List::new(&initial_context));
let (remaining, (raw_value, children)) = consumed(map_parser(
verify(
@ -117,7 +121,9 @@ pub(crate) fn radio_target<'b, 'g, 'r, 's>(
|text| text.len() > 0,
),
confine_context(|i| {
all_consuming(many1(parser_with_context!(minimal_set_object)(context)))(i)
all_consuming(many1(parser_with_context!(minimal_set_object)(
&initial_context,
)))(i)
}),
))(remaining)?;

View File

@ -35,10 +35,12 @@ use super::util::get_consumed;
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;
@ -404,6 +406,9 @@ fn description<'b, 'g, 'r, 's>(
exit_matcher: &description_end,
});
let parser_context = context.with_additional_node(&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),
@ -412,7 +417,7 @@ fn description<'b, 'g, 'r, 's>(
confine_context(|i| {
all_consuming(many1(parser_with_context!(
regular_link_description_set_object
)(context)))(i)
)(&initial_context)))(i)
}),
)(input)?;