Footnote definitions are parsing on their own.

This commit is contained in:
Tom Alexander
2023-04-10 11:50:43 -04:00
parent 45db182421
commit e5bc4cb14b
8 changed files with 68 additions and 18 deletions

View File

@@ -1,3 +1,5 @@
use crate::parser::parser_with_context::parser_with_context;
use super::error::CustomError;
use super::error::MyError;
use super::error::Res;
@@ -10,6 +12,7 @@ use nom::character::complete::none_of;
use nom::character::complete::space0;
use nom::combinator::eof;
use nom::combinator::not;
use nom::combinator::opt;
use nom::combinator::peek;
use nom::combinator::recognize;
use nom::multi::many0;
@@ -89,6 +92,20 @@ pub fn element_trailing_whitespace<'r, 's>(
alt((eof, recognize(many0(blank_line))))(input)
}
#[tracing::instrument(ret, level = "debug")]
pub fn maybe_consume_trailing_whitespace<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, Option<&'s str>> {
if context.should_consume_trailing_whitespace() {
Ok(opt(parser_with_context!(element_trailing_whitespace)(
context,
))(input)?)
} else {
Ok((input, None))
}
}
#[tracing::instrument(ret, level = "debug")]
pub fn trailing_whitespace(input: &str) -> Res<&str, &str> {
alt((eof, recognize(tuple((line_ending, many0(blank_line))))))(input)