Fix handling of text markup at the start/end of regular link descriptions and radio targets.

This commit is contained in:
Tom Alexander
2023-10-09 16:44:59 -04:00
parent 876d042c37
commit 13b95cd0a1
6 changed files with 66 additions and 53 deletions

View File

@@ -1,3 +1,5 @@
use std::fmt::Debug;
use nom::branch::alt;
use nom::character::complete::anychar;
use nom::character::complete::line_ending;
@@ -301,3 +303,28 @@ pub(crate) fn get_has_affiliated_keyword<'b, 'g, 'r, 's>(
}
None
}
/// Reset the input OrgSource as if it was starting a fresh document.
///
/// This is important for making start-of-document, end-of-document, and other context-dependent tests succeed.
pub(crate) fn confine_context<'s, O: Debug, I: Fn(OrgSource<'s>) -> Res<OrgSource<'s>, O>>(
inner: I,
) -> impl Fn(OrgSource<'s>) -> Res<OrgSource<'s>, O> {
move |input| impl_confine_context(input, &inner)
}
/// Reset the input OrgSource as if it was starting a fresh document.
///
/// This is important for making start-of-document, end-of-document, and other context-dependent tests succeed.
#[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(inner))
)]
fn impl_confine_context<'s, O: Debug, I: Fn(OrgSource<'s>) -> Res<OrgSource<'s>, O>>(
input: OrgSource<'s>,
inner: I,
) -> Res<OrgSource<'s>, O> {
let raw_str = Into::<&str>::into(input);
let back_to_org_source = Into::<OrgSource<'_>>::into(raw_str);
inner(back_to_org_source)
}