Switch to ending plain lists with 2 blank lines instead of just 1.

This commit is contained in:
Tom Alexander 2023-03-21 13:36:52 -04:00
parent e3f0aaefdf
commit 2fcb445fe9
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -6,6 +6,8 @@ use nom::character::complete::line_ending;
use nom::character::complete::one_of;
use nom::character::complete::space0;
use nom::combinator::consumed;
use nom::combinator::eof;
use nom::combinator::map;
use nom::combinator::not;
use nom::combinator::opt;
use nom::combinator::peek;
@ -22,10 +24,13 @@ use super::error::Res;
use super::paragraph::paragraph_end;
use super::parser_context::ContextElement;
use super::parser_with_context::parser_with_context;
use super::text::blank_line;
use super::text::line_break;
use super::text::space;
use super::text::text_element;
use super::token::ListItem;
use super::token::PlainList;
use super::token::TextElement;
use super::token::Token;
use super::Context;
@ -114,8 +119,8 @@ pub fn item_end<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, &'
let item_matcher = parser_with_context!(item)(&context);
let line_indented_matcher = parser_with_context!(line_indented_lte)(&context);
alt((
// TODO: This should be two blank lines and it ends ALL of the items
paragraph_end,
// TODO: This should ends the highest plain list
plain_list_end,
recognize(tuple((line_ending, peek(line_indented_matcher)))),
// TODO: Do we still need the item_matcher entry here? If we remove it, then child items should become part of the body of the parent item which would match the description on https://orgmode.org/worg/org-syntax.html
recognize(tuple((line_ending, peek(item_matcher)))),
@ -144,3 +149,14 @@ fn get_context_item_indent<'r, 's>(context: Context<'r, 's>) -> Option<&'r usize
}
None
}
pub fn plain_list_end(input: &str) -> Res<&str, &str> {
alt((
recognize(tuple((
map(line_break, TextElement::LineBreak),
blank_line,
many1(blank_line),
))),
eof,
))(input)
}