Implement parser for inline footnotes.
This commit is contained in:
parent
a36a820e84
commit
b850f59640
@ -15,7 +15,6 @@ use crate::parser::parser_context::FootnoteReferenceDefinition;
|
|||||||
use crate::parser::parser_with_context::parser_with_context;
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
use crate::parser::util::exit_matcher_parser;
|
use crate::parser::util::exit_matcher_parser;
|
||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::not_yet_implemented;
|
|
||||||
use crate::parser::FootnoteReference;
|
use crate::parser::FootnoteReference;
|
||||||
use crate::parser::Object;
|
use crate::parser::Object;
|
||||||
|
|
||||||
@ -39,6 +38,7 @@ fn anonymous_footnote<'r, 's>(
|
|||||||
depth: 0,
|
depth: 0,
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
// TODO: I could insert FootnoteReferenceDefinition entries in the context after each matched object to reduce the scanning done for counting brackets which should be more efficient.
|
||||||
let (remaining, (children, _exit_contents)) = verify(
|
let (remaining, (children, _exit_contents)) = verify(
|
||||||
many_till(
|
many_till(
|
||||||
parser_with_context!(standard_set_object)(&parser_context),
|
parser_with_context!(standard_set_object)(&parser_context),
|
||||||
@ -63,8 +63,33 @@ fn inline_footnote<'r, 's>(
|
|||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
) -> Res<&'s str, FootnoteReference<'s>> {
|
) -> Res<&'s str, FootnoteReference<'s>> {
|
||||||
not_yet_implemented()?;
|
let (remaining, _) = tag_no_case("[fn:")(input)?;
|
||||||
todo!()
|
let (remaining, label_contents) = label(remaining)?;
|
||||||
|
let (remaining, _) = tag(":")(remaining)?;
|
||||||
|
let parser_context = context.with_additional_node(ContextElement::FootnoteReferenceDefinition(
|
||||||
|
FootnoteReferenceDefinition {
|
||||||
|
position: remaining,
|
||||||
|
depth: 0,
|
||||||
|
},
|
||||||
|
));
|
||||||
|
// TODO: I could insert FootnoteReferenceDefinition entries in the context after each matched object to reduce the scanning done for counting brackets which should be more efficient.
|
||||||
|
let (remaining, (children, _exit_contents)) = verify(
|
||||||
|
many_till(
|
||||||
|
parser_with_context!(standard_set_object)(&parser_context),
|
||||||
|
parser_with_context!(exit_matcher_parser)(&parser_context),
|
||||||
|
),
|
||||||
|
|(children, exit_contents)| !children.is_empty() && exit_contents == &"]",
|
||||||
|
)(remaining)?;
|
||||||
|
|
||||||
|
let source = get_consumed(input, remaining);
|
||||||
|
Ok((
|
||||||
|
remaining,
|
||||||
|
FootnoteReference {
|
||||||
|
source,
|
||||||
|
label: Some(label_contents),
|
||||||
|
definition: children,
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
|
Loading…
Reference in New Issue
Block a user