From 6a1bdd5feed112b80d8c12340a642b1227d921b3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 8 Sep 2023 21:11:47 -0400 Subject: [PATCH] Support blank lines before content in footnote definitions. --- .../empty_space_before_and_after_content.org | 1 - src/parser/footnote_definition.rs | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/org_mode_samples/greater_element/footnote_definition/empty_space_before_and_after_content.org b/org_mode_samples/greater_element/footnote_definition/empty_space_before_and_after_content.org index 1d2113ea..68622132 100644 --- a/org_mode_samples/greater_element/footnote_definition/empty_space_before_and_after_content.org +++ b/org_mode_samples/greater_element/footnote_definition/empty_space_before_and_after_content.org @@ -6,4 +6,3 @@ baz #+END_EXAMPLE - diff --git a/src/parser/footnote_definition.rs b/src/parser/footnote_definition.rs index e413d9d6..be8b0e3f 100644 --- a/src/parser/footnote_definition.rs +++ b/src/parser/footnote_definition.rs @@ -4,8 +4,10 @@ use nom::bytes::complete::tag_no_case; use nom::bytes::complete::take_while; use nom::character::complete::digit1; use nom::character::complete::space0; +use nom::combinator::opt; use nom::combinator::recognize; use nom::combinator::verify; +use nom::multi::many0; use nom::multi::many1; use nom::multi::many_till; use nom::sequence::tuple; @@ -41,8 +43,15 @@ pub fn footnote_definition<'b, 'g, 'r, 's>( } start_of_line(input)?; // Cannot be indented. - let (remaining, (_lead_in, lbl, _lead_out, _ws)) = - tuple((tag_no_case("[fn:"), label, tag("]"), space0))(input)?; + let (remaining, (_, lbl, _, _, _)) = tuple(( + tag_no_case("[fn:"), + label, + tag("]"), + space0, + opt(verify(many0(blank_line), |lines: &Vec>| { + lines.len() <= 2 + })), + ))(input)?; let contexts = [ ContextElement::ConsumeTrailingWhitespace(true), ContextElement::Context("footnote definition"),