From 895ee9f3b6bb542af1c2b7e383f62b57976ea9bf Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 10 Apr 2023 12:16:49 -0400 Subject: [PATCH] Add a test showing the footnote exit matcher is not handling multiple blank lines properly. --- src/parser/footnote_definition.rs | 27 +++++++++++++++++++++++++++ toy_language.txt | 3 +++ 2 files changed, 30 insertions(+) diff --git a/src/parser/footnote_definition.rs b/src/parser/footnote_definition.rs index 0c7f714..5e53645 100644 --- a/src/parser/footnote_definition.rs +++ b/src/parser/footnote_definition.rs @@ -124,4 +124,31 @@ line footnote."; line footnote." ); } + + #[test] + fn multiline_break() { + let input = "[fn:2] A multi- + +line footnote. + + +not in the 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"); + assert_eq!(remaining, "not in the footnote."); + assert_eq!( + first_footnote_definition.source, + "[fn:2] A multi- + +line footnote. + + +" + ); + } } diff --git a/toy_language.txt b/toy_language.txt index 5d18333..d953b9f 100644 --- a/toy_language.txt +++ b/toy_language.txt @@ -33,3 +33,6 @@ foo bar [fn:2] A multi- line footnote. + + +not in the footnote.