Expose a document parser and implement the paragraph parser so something is hitting our macro.
This commit is contained in:
@@ -18,10 +18,14 @@ use nom::character::complete::space1;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::recognize;
|
||||
use nom::error::VerboseError;
|
||||
use nom::multi::many1;
|
||||
use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
use nom::IResult;
|
||||
|
||||
use super::nom_context::NomContext;
|
||||
use super::text_element_parser::text_element;
|
||||
|
||||
pub type Res<T, U> = IResult<T, U, VerboseError<T>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -125,10 +129,14 @@ pub fn link_end(input: &str) -> Res<&str, TextElement> {
|
||||
}
|
||||
|
||||
pub fn paragraph(input: &str) -> Res<&str, (Vec<TextElement>, &str)> {
|
||||
todo!()
|
||||
// many_till(TextElementParser::new(paragraph_end), paragraph_end)(input)
|
||||
let initial_context = NomContext::new(¶graph_end);
|
||||
many_till(text_element(initial_context), paragraph_end)(input)
|
||||
}
|
||||
|
||||
fn paragraph_end(input: &str) -> Res<&str, &str> {
|
||||
recognize(tuple((map(line_break, TextElement::LineBreak), blank_line)))(input)
|
||||
}
|
||||
|
||||
pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
|
||||
many1(paragraph)(input)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user