Detect next list item as ender for current list item.
This commit is contained in:
parent
88c974f8e4
commit
29904f2bb5
@ -23,7 +23,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// let parsed = document(TEST_DOC);
|
// let parsed = document(TEST_DOC);
|
||||||
// println!("{}\n\n\n", TEST_DOC);
|
// println!("{}\n\n\n", TEST_DOC);
|
||||||
let initial_context: ContextTree<'_, '_> = ContextTree::new();
|
let initial_context: ContextTree<'_, '_> = ContextTree::new();
|
||||||
let parsed = item(&initial_context, " 1. foo\n");
|
let parsed = item(&initial_context, " 1. foo\n2. bar");
|
||||||
println!("{:#?}", parsed);
|
println!("{:#?}", parsed);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ use nom::character::complete::space0;
|
|||||||
use nom::combinator::consumed;
|
use nom::combinator::consumed;
|
||||||
use nom::combinator::not;
|
use nom::combinator::not;
|
||||||
use nom::combinator::opt;
|
use nom::combinator::opt;
|
||||||
|
use nom::combinator::peek;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::multi::many0_count;
|
use nom::multi::many0_count;
|
||||||
use nom::multi::many1;
|
use nom::multi::many1;
|
||||||
@ -17,6 +18,7 @@ use super::combinator::context_many_till;
|
|||||||
use super::error::Res;
|
use super::error::Res;
|
||||||
use super::paragraph::paragraph_end;
|
use super::paragraph::paragraph_end;
|
||||||
use super::parser_context::ContextElement;
|
use super::parser_context::ContextElement;
|
||||||
|
use super::parser_with_context::parser_with_context;
|
||||||
use super::text::space;
|
use super::text::space;
|
||||||
use super::text::text_element;
|
use super::text::text_element;
|
||||||
use super::token::ListItem;
|
use super::token::ListItem;
|
||||||
@ -107,5 +109,9 @@ fn tag_separator<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn item_end<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, &'s str> {
|
pub fn item_end<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, &'s str> {
|
||||||
paragraph_end(i)
|
let item_matcher = parser_with_context!(item)(&context);
|
||||||
|
alt((
|
||||||
|
paragraph_end,
|
||||||
|
recognize(tuple((line_ending, peek(item_matcher)))),
|
||||||
|
))(i)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user