diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 4d026e5..c2cf0ec 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -4,12 +4,17 @@ use nom::character::complete::anychar; use nom::character::complete::digit1; use nom::character::complete::line_ending; use nom::character::complete::one_of; +use nom::combinator::consumed; use nom::combinator::not; +use nom::combinator::opt; use nom::combinator::recognize; use nom::multi::many1; use nom::sequence::tuple; +use super::combinator::context_many_till; use super::error::Res; +use super::text::space; +use super::text::text_element; use super::token::ListItem; use super::token::PlainList; use super::Context; @@ -20,6 +25,14 @@ pub fn plain_list<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, } fn item<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, ListItem<'s>> { + let _ = consumed(tuple(( + bullet, + opt(tuple((space, counter_set))), + opt(tuple((space, check_box))), + opt(tuple((space, item_tag))), + space, + context_many_till(context, text_element, item_end), + )))(i)?; // todo todo!() } @@ -61,3 +74,8 @@ fn tag_text_character<'s>(i: &'s str) -> Res<&'s str, &'s str> { fn tag_separator<'s>(i: &'s str) -> Res<&'s str, &'s str> { tag(" :: ")(i) } + +pub fn item_end<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, &'s str> { + // todo + todo!() +} diff --git a/src/parser/text.rs b/src/parser/text.rs index 4aaf632..a82a8df 100644 --- a/src/parser/text.rs +++ b/src/parser/text.rs @@ -24,7 +24,7 @@ pub fn line_break(input: &str) -> Res<&str, LineBreak> { map(line_ending, |s: &str| LineBreak { source: s })(input) } -fn space(input: &str) -> Res<&str, Space> { +pub fn space(input: &str) -> Res<&str, Space> { map(space1, |s: &str| Space { source: s })(input) } diff --git a/src/parser/token.rs b/src/parser/token.rs index 9d4c7a8..1153a54 100644 --- a/src/parser/token.rs +++ b/src/parser/token.rs @@ -110,6 +110,11 @@ impl<'a> Source<'a> for PlainList<'a> { #[derive(Debug)] pub struct ListItem<'a> { pub source: &'a str, + pub bullet: &'a str, + pub counter_set: &'a str, + pub check_box: &'a str, + pub item_tag: &'a str, + pub contents: Vec>, } impl<'a> Source<'a> for ListItem<'a> {