Start of list item implementation.

This commit is contained in:
Tom Alexander 2022-12-18 07:18:42 -05:00
parent 62e5499150
commit 5e7c891681
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 24 additions and 1 deletions

View File

@ -4,12 +4,17 @@ use nom::character::complete::anychar;
use nom::character::complete::digit1; use nom::character::complete::digit1;
use nom::character::complete::line_ending; use nom::character::complete::line_ending;
use nom::character::complete::one_of; use nom::character::complete::one_of;
use nom::combinator::consumed;
use nom::combinator::not; use nom::combinator::not;
use nom::combinator::opt;
use nom::combinator::recognize; use nom::combinator::recognize;
use nom::multi::many1; use nom::multi::many1;
use nom::sequence::tuple; use nom::sequence::tuple;
use super::combinator::context_many_till;
use super::error::Res; use super::error::Res;
use super::text::space;
use super::text::text_element;
use super::token::ListItem; use super::token::ListItem;
use super::token::PlainList; use super::token::PlainList;
use super::Context; 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>> { 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
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> { fn tag_separator<'s>(i: &'s str) -> Res<&'s str, &'s str> {
tag(" :: ")(i) tag(" :: ")(i)
} }
pub fn item_end<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, &'s str> {
// todo
todo!()
}

View File

@ -24,7 +24,7 @@ pub fn line_break(input: &str) -> Res<&str, LineBreak> {
map(line_ending, |s: &str| LineBreak { source: s })(input) 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) map(space1, |s: &str| Space { source: s })(input)
} }

View File

@ -110,6 +110,11 @@ impl<'a> Source<'a> for PlainList<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct ListItem<'a> { pub struct ListItem<'a> {
pub source: &'a str, 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<TextElement<'a>>,
} }
impl<'a> Source<'a> for ListItem<'a> { impl<'a> Source<'a> for ListItem<'a> {