Convert all functions to using the wrapped input type.
This commit is contained in:
@@ -5,6 +5,7 @@ use nom::character::complete::space0;
|
||||
use nom::combinator::verify;
|
||||
use nom::multi::many_till;
|
||||
|
||||
use super::org_source::OrgSource;
|
||||
use super::parser_context::ContextElement;
|
||||
use super::Context;
|
||||
use crate::error::CustomError;
|
||||
@@ -24,8 +25,8 @@ use crate::parser::Object;
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn footnote_reference<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, FootnoteReference<'s>> {
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, FootnoteReference<'s>> {
|
||||
alt((
|
||||
parser_with_context!(anonymous_footnote)(context),
|
||||
parser_with_context!(footnote_reference_only)(context),
|
||||
@@ -36,8 +37,8 @@ pub fn footnote_reference<'r, 's>(
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn anonymous_footnote<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, FootnoteReference<'s>> {
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, FootnoteReference<'s>> {
|
||||
let (remaining, _) = tag_no_case("[fn::")(input)?;
|
||||
let parser_context = context
|
||||
.with_additional_node(ContextElement::FootnoteReferenceDefinition(
|
||||
@@ -65,7 +66,7 @@ fn anonymous_footnote<'r, 's>(
|
||||
Ok((
|
||||
remaining,
|
||||
FootnoteReference {
|
||||
source,
|
||||
source: source.into(),
|
||||
label: None,
|
||||
definition: children,
|
||||
},
|
||||
@@ -75,8 +76,8 @@ fn anonymous_footnote<'r, 's>(
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn inline_footnote<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, FootnoteReference<'s>> {
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, FootnoteReference<'s>> {
|
||||
let (remaining, _) = tag_no_case("[fn:")(input)?;
|
||||
let (remaining, label_contents) = label(remaining)?;
|
||||
let (remaining, _) = tag(":")(remaining)?;
|
||||
@@ -106,8 +107,8 @@ fn inline_footnote<'r, 's>(
|
||||
Ok((
|
||||
remaining,
|
||||
FootnoteReference {
|
||||
source,
|
||||
label: Some(label_contents),
|
||||
source: source.into(),
|
||||
label: Some(label_contents.into()),
|
||||
definition: children,
|
||||
},
|
||||
))
|
||||
@@ -116,8 +117,8 @@ fn inline_footnote<'r, 's>(
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn footnote_reference_only<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, FootnoteReference<'s>> {
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, FootnoteReference<'s>> {
|
||||
let (remaining, _) = tag_no_case("[fn:")(input)?;
|
||||
let (remaining, label_contents) = label(remaining)?;
|
||||
let (remaining, _) = tag("]")(remaining)?;
|
||||
@@ -126,28 +127,28 @@ fn footnote_reference_only<'r, 's>(
|
||||
Ok((
|
||||
remaining,
|
||||
FootnoteReference {
|
||||
source,
|
||||
label: Some(label_contents),
|
||||
source: source.into(),
|
||||
label: Some(label_contents.into()),
|
||||
definition: Vec::with_capacity(0),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn definition<'s>(input: &'s str) -> Res<&'s str, Vec<Object<'s>>> {
|
||||
fn definition<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, Vec<Object<'s>>> {
|
||||
Ok((input, vec![]))
|
||||
}
|
||||
|
||||
#[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 context_depth = get_bracket_depth(context)
|
||||
.expect("This function should only be called from inside a footnote definition.");
|
||||
let text_since_context_entry = get_consumed(context_depth.position, input);
|
||||
let mut current_depth = context_depth.depth;
|
||||
for c in text_since_context_entry.chars() {
|
||||
for c in Into::<&str>::into(text_since_context_entry).chars() {
|
||||
match c {
|
||||
'[' => {
|
||||
current_depth += 1;
|
||||
@@ -164,7 +165,7 @@ fn footnote_definition_end<'r, 's>(
|
||||
if current_depth > 0 {
|
||||
// Its impossible for the next character to end the footnote reference definition if we're any amount of brackets deep
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"NoFootnoteReferenceDefinitionEnd",
|
||||
"NoFootnoteReferenceDefinitionEnd".into(),
|
||||
))));
|
||||
}
|
||||
tag("]")(input)
|
||||
|
||||
Reference in New Issue
Block a user