From f0a7493a897942b3ca36010d1873f10b78fc839c Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Sep 2023 22:03:21 -0400 Subject: [PATCH] Support blank lines for descriptive list with empty value before final list item. --- .../greater_element/plain_list/description_list.org | 5 ----- .../plain_list/description_list_empty_value.org | 6 ++++++ src/parser/plain_list.rs | 7 ++++++- 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 org_mode_samples/greater_element/plain_list/description_list_empty_value.org diff --git a/org_mode_samples/greater_element/plain_list/description_list.org b/org_mode_samples/greater_element/plain_list/description_list.org index f134c955..5bbcedfd 100644 --- a/org_mode_samples/greater_element/plain_list/description_list.org +++ b/org_mode_samples/greater_element/plain_list/description_list.org @@ -9,8 +9,3 @@ - big gap :: stuff -- empty value with blank non-final :: - -- empty value with blank final :: - -stuff diff --git a/org_mode_samples/greater_element/plain_list/description_list_empty_value.org b/org_mode_samples/greater_element/plain_list/description_list_empty_value.org new file mode 100644 index 00000000..123ba10c --- /dev/null +++ b/org_mode_samples/greater_element/plain_list/description_list_empty_value.org @@ -0,0 +1,6 @@ +- foo :: + +- bar :: + + +baz diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 3f73f4c5..efabcb78 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -187,7 +187,11 @@ fn plain_list_item<'b, 'g, 'r, 's>( )(&parser_context))(remaining); match maybe_contentless_item { Ok((_rem, _ws)) => { - let (remaining, _trailing_ws) = opt(blank_line)(remaining)?; + let (remaining, _trailing_ws) = if context.should_consume_trailing_whitespace() { + recognize(many0(blank_line))(remaining)? + } else { + recognize(opt(blank_line))(remaining)? + }; let source = get_consumed(input, remaining); return Ok(( remaining, @@ -245,6 +249,7 @@ fn plain_list_item<'b, 'g, 'r, 's>( )); } +#[derive(Debug)] enum BulletType { Ordered, Unordered,