Start of list item implementation.
This commit is contained in:
parent
62e5499150
commit
5e7c891681
@ -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!()
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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<TextElement<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> Source<'a> for ListItem<'a> {
|
||||
|
Loading…
Reference in New Issue
Block a user