diff --git a/src/parser/document.rs b/src/parser/document.rs index 6d2e2da..b2e3541 100644 --- a/src/parser/document.rs +++ b/src/parser/document.rs @@ -1,8 +1,18 @@ +use crate::parser::comment::comment; +use crate::parser::element::element; +use crate::parser::exiting::ExitClass; +use crate::parser::object::standard_set_object; +use crate::parser::parser_context::ContextElement; +use crate::parser::parser_context::ContextTree; +use crate::parser::parser_context::ExitMatcherNode; use crate::parser::property_drawer::property_drawer; +use crate::parser::util::blank_line; +use crate::parser::util::maybe_consume_trailing_whitespace_if_not_exiting; use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::line_ending; use nom::character::complete::space1; +use nom::combinator::eof; use nom::combinator::map; use nom::combinator::not; use nom::combinator::opt; @@ -14,16 +24,6 @@ use nom::multi::many1_count; use nom::multi::many_till; use nom::sequence::tuple; -use crate::parser::comment::comment; -use crate::parser::element::element; -use crate::parser::exiting::ExitClass; -use crate::parser::object::standard_set_object; -use crate::parser::parser_context::ContextElement; -use crate::parser::parser_context::ContextTree; -use crate::parser::parser_context::ExitMatcherNode; -use crate::parser::util::blank_line; -use crate::parser::util::maybe_consume_trailing_whitespace_if_not_exiting; - use super::element::Element; use super::error::Res; use super::object::Object; @@ -234,11 +234,12 @@ fn headline<'r, 's>( let standard_set_object_matcher = parser_with_context!(standard_set_object)(&parser_context); let start_of_line_matcher = parser_with_context!(start_of_line)(&parser_context); - let (remaining, (_sol, star_count, ws, title)) = tuple(( + let (remaining, (_sol, star_count, ws, title, _line_ending)) = tuple(( start_of_line_matcher, many1_count(tag("*")), space1, many1(standard_set_object_matcher), + alt((line_ending, eof)), ))(input)?; Ok((remaining, (star_count, ws, title))) }