Going to try to make the functions in the context more generic.

This commit is contained in:
Tom Alexander
2022-10-14 20:06:10 -04:00
parent c958136949
commit 262bd3c061
3 changed files with 9 additions and 107 deletions

View File

@@ -25,7 +25,6 @@ use nom::IResult;
use super::nom_context::NomContext;
use super::parser_with_context::parser_with_context;
use super::text_element_parser::paragraph;
pub type Res<T, U> = IResult<T, U, VerboseError<T>>;
@@ -129,17 +128,12 @@ pub fn link_end(input: &str) -> Res<&str, TextElement> {
map(symbol("]"), TextElement::Symbol)(input)
}
// pub fn paragraph(input: &str) -> Res<&str, (Vec<TextElement>, &str)> {
// // let initial_context = NomContext::new(&paragraph_end);
// // many_till(text_element(initial_context), paragraph_end)(input)
// todo!()
// }
pub 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)>> {
let initial_context = NomContext::new(&paragraph_end);
many1(parser_with_context!(paragraph)(initial_context))(input)
todo!()
// many1(parser_with_context!(paragraph)(initial_context))(input)
}