Add parsers for most of the rest of item.
This commit is contained in:
parent
b4e28f3d4d
commit
62e5499150
@ -1,8 +1,12 @@
|
|||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
|
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::one_of;
|
use nom::character::complete::one_of;
|
||||||
|
use nom::combinator::not;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
|
use nom::multi::many1;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::error::Res;
|
use super::error::Res;
|
||||||
@ -32,3 +36,28 @@ fn bullet<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
|||||||
recognize(tuple((counter, alt((tag("."), tag(")")))))),
|
recognize(tuple((counter, alt((tag("."), tag(")")))))),
|
||||||
))(i)
|
))(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn counter_set<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
||||||
|
recognize(tuple((tag("[@"), counter, tag("]"))))(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_box<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
||||||
|
recognize(alt((tag("[ ]"), tag("[X]"), tag("[-]"))))(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn item_tag<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
||||||
|
recognize(tuple((tag_text, tag_separator)))(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tag_text<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
||||||
|
recognize(many1(tag_text_character))(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tag_text_character<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
||||||
|
not(alt((tag_separator, line_ending)))(i)?;
|
||||||
|
recognize(anychar)(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tag_separator<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
||||||
|
tag(" :: ")(i)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user