Clean up paragraph eof detection.
This commit is contained in:
parent
65c51f79d6
commit
99f9450eda
@ -20,6 +20,7 @@ use super::text::Link;
|
||||
use super::text::Res;
|
||||
use super::text::TextElement;
|
||||
use nom::branch::alt;
|
||||
use nom::combinator::eof;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::not;
|
||||
use nom::combinator::recognize;
|
||||
@ -87,18 +88,11 @@ pub fn paragraph<'s, 'r>(
|
||||
i: &'s str,
|
||||
context: &'r OrgModeContext<'r>,
|
||||
) -> Res<&'s str, (Vec<TextElement<'s>>, &'s str)> {
|
||||
// not(eof)(i)?;
|
||||
// Add a not(eof) check because many_till cannot match a zero-length string
|
||||
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user