diff --git a/src/parser/footnote_definition.rs b/src/parser/footnote_definition.rs index 4e3403b..661b5d2 100644 --- a/src/parser/footnote_definition.rs +++ b/src/parser/footnote_definition.rs @@ -84,3 +84,43 @@ fn footnote_definition_end<'r, 's>( ))), ))(input) } + +#[cfg(test)] +mod tests { + use crate::parser::parser_context::ContextElement; + use crate::parser::parser_context::ContextTree; + use crate::parser::parser_with_context::parser_with_context; + + use super::*; + + #[test] + fn two_paragraphs() { + let input = "[fn:1] A footnote. + +[fn:2] A multi- + +line footnote."; + let initial_context: ContextTree<'_, '_> = ContextTree::new(); + let document_context = + initial_context.with_additional_node(ContextElement::DocumentRoot(input)); + let footnote_definition_matcher = + parser_with_context!(footnote_definition)(&document_context); + let (remaining, first_footnote_definition) = + footnote_definition_matcher(input).expect("Parse first footnote_definition"); + let (remaining, second_footnote_definition) = + footnote_definition_matcher(remaining).expect("Parse second footnote_definition."); + assert_eq!(remaining, ""); + assert_eq!( + first_footnote_definition.source, + "[fn:1] A footnote. + +" + ); + assert_eq!( + second_footnote_definition.source, + "[fn:2] A multi- + +line footnote." + ); + } +}