diff --git a/org_mode_samples/lesser_element/diary_sexp/with_comment_at_end_of_line.org b/org_mode_samples/lesser_element/diary_sexp/with_comment_at_end_of_line.org new file mode 100644 index 0000000..86af989 --- /dev/null +++ b/org_mode_samples/lesser_element/diary_sexp/with_comment_at_end_of_line.org @@ -0,0 +1 @@ +%%(foo bar) ; baz diff --git a/src/parser/diary_sexp.rs b/src/parser/diary_sexp.rs index 6d403dc..691f990 100644 --- a/src/parser/diary_sexp.rs +++ b/src/parser/diary_sexp.rs @@ -1,9 +1,12 @@ use nom::branch::alt; use nom::bytes::complete::tag; +use nom::character::complete::anychar; use nom::character::complete::line_ending; use nom::character::complete::space0; use nom::combinator::eof; +use nom::combinator::opt; use nom::combinator::recognize; +use nom::multi::many_till; use nom::sequence::tuple; use super::org_source::OrgSource; @@ -24,6 +27,11 @@ pub fn diary_sexp<'r, 's>( let (remaining, _clock) = tag("%%")(remaining)?; let (remaining, _gap_whitespace) = space0(remaining)?; let (remaining, _sexp) = recognize(sexp)(remaining)?; + let (remaining, _trailing_comment) = opt(tuple(( + space0, + tag(";"), + many_till(anychar, alt((line_ending, eof))), + )))(remaining)?; let (remaining, _trailing_whitespace) = recognize(tuple((space0, alt((line_ending, eof)))))(remaining)?;