Update diary sexp parser to match org-mode's behavior.

main
Tom Alexander 9 months ago
parent f54081437a
commit f103d168d5
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -1,16 +1,11 @@
use nom::branch::alt;
use nom::bytes::complete::is_not;
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;
use super::sexp::sexp;
use crate::context::RefContext;
use crate::error::Res;
use crate::parser::util::get_consumed;
@ -23,15 +18,9 @@ pub fn diary_sexp<'b, 'g, 'r, 's>(
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, DiarySexp<'s>> {
start_of_line(input)?;
let (remaining, _clock) = tag("%%")(input)?;
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)?;
let (remaining, _clock) = tag("%%(")(input)?;
let (remaining, _contents) = is_not("\r\n")(remaining)?;
let (remaining, _eol) = alt((line_ending, eof))(remaining)?;
let source = get_consumed(input, remaining);
Ok((

Loading…
Cancel
Save