Convert all functions to using the wrapped input type.
Some checks failed
rust-test Build rust-test has failed
rust-build Build rust-build has failed

This commit is contained in:
Tom Alexander
2023-08-23 00:30:26 -04:00
parent b7a5dd48ea
commit dab598e5e7
45 changed files with 1217 additions and 572 deletions

View File

@@ -10,6 +10,7 @@ use nom::multi::many1;
use nom::multi::many_till;
use nom::sequence::tuple;
use super::org_source::OrgSource;
use super::util::WORD_CONSTITUENT_CHARACTERS;
use super::Context;
use crate::error::CustomError;
@@ -31,11 +32,11 @@ use crate::parser::util::start_of_line;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn footnote_definition<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, FootnoteDefinition<'s>> {
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, FootnoteDefinition<'s>> {
if immediate_in_section(context, "footnote definition") {
return Err(nom::Err::Error(CustomError::MyError(MyError(
"Cannot nest objects of the same element",
"Cannot nest objects of the same element".into(),
))));
}
start_of_line(context, input)?;
@@ -59,15 +60,15 @@ pub fn footnote_definition<'r, 's>(
Ok((
remaining,
FootnoteDefinition {
source,
label: lbl,
source: source.into(),
label: lbl.into(),
children,
},
))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn label<'s>(input: &'s str) -> Res<&'s str, &'s str> {
pub fn label<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
alt((
digit1,
take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c)),
@@ -77,8 +78,8 @@ pub fn label<'s>(input: &'s str) -> Res<&'s str, &'s str> {
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn footnote_definition_end<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, &'s str> {
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let start_of_line_matcher = parser_with_context!(start_of_line)(context);
let allow_nesting_context =
context.with_additional_node(ContextElement::Context("allow nesting footnotes"));
@@ -98,7 +99,9 @@ fn footnote_definition_end<'r, 's>(
))),
recognize(tuple((
start_of_line_matcher,
verify(many1(blank_line), |lines: &Vec<&str>| lines.len() >= 2),
verify(many1(blank_line), |lines: &Vec<OrgSource<'_>>| {
lines.len() >= 2
}),
))),
))(input)?;