From b65c2f86b5a64117c8a6a7d0c041f5b001b70dae Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 25 Mar 2023 11:49:56 -0400 Subject: [PATCH] Consume trailing whitespace in paragraphs. --- src/parser/element.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/parser/element.rs b/src/parser/element.rs index 5a0fa10..88d44cc 100644 --- a/src/parser/element.rs +++ b/src/parser/element.rs @@ -5,6 +5,7 @@ use nom::combinator::eof; use nom::combinator::map; use nom::combinator::not; use nom::combinator::recognize; +use nom::multi::many0; use nom::multi::many1; use nom::sequence::tuple; @@ -53,6 +54,9 @@ fn paragraph<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, P let (remaining, children) = many1(standard_set_object_matcher)(input)?; + let (remaining, _trailing_whitespace) = + alt((eof, recognize(tuple((line_ending, many0(blank_line))))))(remaining)?; + let source = get_consumed(input, remaining); Ok((remaining, Paragraph { source, children }))