Update the paragraph parser to work at the end of the file.
This commit is contained in:
@@ -23,11 +23,14 @@ use nom::branch::alt;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::not;
|
||||
use nom::combinator::recognize;
|
||||
use nom::error::ErrorKind;
|
||||
use nom::error::ParseError;
|
||||
use nom::error::VerboseError;
|
||||
use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
use nom::IResult;
|
||||
use tracing::instrument;
|
||||
use tracing::trace;
|
||||
|
||||
fn flat_text_element<'s, 'r>(
|
||||
i: &'s str,
|
||||
@@ -84,8 +87,18 @@ pub fn paragraph<'s, 'r>(
|
||||
i: &'s str,
|
||||
context: &'r OrgModeContext<'r>,
|
||||
) -> Res<&'s str, (Vec<TextElement<'s>>, &'s str)> {
|
||||
// not(eof)(i)?;
|
||||
let paragraph_context = context.with_additional_fail_matcher(¶graph_end);
|
||||
let text_element_parser = parser_with_context!(flat_text_element)(¶graph_context);
|
||||
let ret = many_till(text_element_parser, paragraph_end)(i);
|
||||
trace!("Returning from paragraph with {:#?}", ret);
|
||||
if let Ok((remaining, (text_elements, end_of_paragraph))) = &ret {
|
||||
if text_elements.len() == 0 {
|
||||
return Err(nom::Err::Error(nom::error::VerboseError::from_error_kind(
|
||||
remaining,
|
||||
ErrorKind::ManyTill,
|
||||
)));
|
||||
}
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user