use nom::branch::alt; use nom::bytes::complete::is_not; use nom::bytes::complete::tag; use nom::character::complete::line_ending; use nom::combinator::eof; use nom::sequence::tuple; use super::org_source::OrgSource; use crate::context::RefContext; use crate::error::Res; use crate::parser::util::get_consumed; use crate::parser::util::start_of_line; use crate::types::DiarySexp; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] pub(crate) fn diary_sexp<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, DiarySexp<'s>> { start_of_line(input)?; 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(( remaining, DiarySexp { source: source.into(), }, )) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] pub(crate) fn detect_diary_sexp<'s>(input: OrgSource<'s>) -> Res, ()> { tuple((start_of_line, tag("%%(")))(input)?; Ok((input, ())) }