Compare commits
No commits in common. "f192507cd992bebcc54bb11b8744589debbf0d34" and "28f12a04f7af8ef6e81df76754249050dcc0d364" have entirely different histories.
f192507cd9
...
28f12a04f7
@ -82,7 +82,7 @@ fn clock_timestamp<'b, 'g, 'r, 's>(
|
||||
|(timestamp, duration)| (timestamp, duration.map(Into::<&str>::into)),
|
||||
),
|
||||
map(
|
||||
parser_with_context!(inactive_timestamp(true))(context),
|
||||
parser_with_context!(inactive_timestamp)(context),
|
||||
|timestamp| (timestamp, None),
|
||||
),
|
||||
))(input)
|
||||
|
@ -31,7 +31,7 @@ where
|
||||
let (remaining, value) = recognize(tuple((tag("%%("), is_not("\r\n"))))(remaining)?;
|
||||
let (remaining, _eol) = org_line_ending(remaining)?;
|
||||
|
||||
let (remaining, post_blank) =
|
||||
let (remaining, _trailing_ws) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((
|
||||
@ -43,7 +43,6 @@ where
|
||||
affiliated_keywords,
|
||||
),
|
||||
value: Into::<&str>::into(value),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ pub(crate) fn timestamp<'b, 'g, 'r, 's>(
|
||||
parser_with_context!(inactive_time_range_timestamp)(context),
|
||||
parser_with_context!(active_date_range_timestamp)(context),
|
||||
parser_with_context!(inactive_date_range_timestamp)(context),
|
||||
parser_with_context!(active_timestamp(true))(context),
|
||||
parser_with_context!(inactive_timestamp(true))(context),
|
||||
parser_with_context!(active_timestamp)(context),
|
||||
parser_with_context!(inactive_timestamp)(context),
|
||||
))(input)
|
||||
}
|
||||
|
||||
@ -126,23 +126,13 @@ fn sexp_end<'b, 'g, 'r, 's>(
|
||||
alt((tag(")>"), recognize(one_of(">\n"))))(input)
|
||||
}
|
||||
|
||||
const fn active_timestamp(
|
||||
allow_post_blank: bool,
|
||||
) -> impl for<'b, 'g, 'r, 's> Fn(
|
||||
RefContext<'b, 'g, 'r, 's>,
|
||||
OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
move |context, input| impl_active_timestamp(context, input, allow_post_blank)
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "tracing",
|
||||
tracing::instrument(ret, level = "debug", skip(context))
|
||||
)]
|
||||
fn impl_active_timestamp<'b, 'g, 'r, 's>(
|
||||
fn active_timestamp<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
allow_post_blank: bool,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, _) = tag("<")(input)?;
|
||||
let (remaining, start) = date(context, remaining)?;
|
||||
@ -170,11 +160,8 @@ fn impl_active_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag(">")(remaining)?;
|
||||
|
||||
let (remaining, post_blank) = if allow_post_blank {
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?
|
||||
} else {
|
||||
(remaining, None)
|
||||
};
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
Ok((
|
||||
@ -194,23 +181,13 @@ fn impl_active_timestamp<'b, 'g, 'r, 's>(
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) const fn inactive_timestamp(
|
||||
allow_post_blank: bool,
|
||||
) -> impl for<'b, 'g, 'r, 's> Fn(
|
||||
RefContext<'b, 'g, 'r, 's>,
|
||||
OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
move |context, input| impl_inactive_timestamp(context, input, allow_post_blank)
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "tracing",
|
||||
tracing::instrument(ret, level = "debug", skip(context))
|
||||
)]
|
||||
fn impl_inactive_timestamp<'b, 'g, 'r, 's>(
|
||||
pub(crate) fn inactive_timestamp<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
allow_post_blank: bool,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, _) = tag("[")(input)?;
|
||||
let (remaining, start) = date(context, remaining)?;
|
||||
@ -238,11 +215,8 @@ fn impl_inactive_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag("]")(remaining)?;
|
||||
|
||||
let (remaining, post_blank) = if allow_post_blank {
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?
|
||||
} else {
|
||||
(remaining, None)
|
||||
};
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
Ok((
|
||||
@ -270,10 +244,10 @@ fn active_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, first_timestamp) = impl_active_timestamp(context, input, false)?;
|
||||
let (remaining, first_timestamp) = active_timestamp(context, input)?;
|
||||
// TODO: Does the space0 at the end of the active/inactive timestamp parsers cause this to be incorrect? I could use a look-behind to make sure the preceding character is not whitespace
|
||||
let (remaining, _separator) = tag("--")(remaining)?;
|
||||
let (remaining, second_timestamp) = impl_active_timestamp(context, remaining, false)?;
|
||||
let (remaining, second_timestamp) = active_timestamp(context, remaining)?;
|
||||
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
@ -361,10 +335,10 @@ pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, first_timestamp) = impl_inactive_timestamp(context, input, false)?;
|
||||
let (remaining, first_timestamp) = inactive_timestamp(context, input)?;
|
||||
// TODO: Does the space0 at the end of the active/inactive timestamp parsers cause this to be incorrect? I could use a look-behind to make sure the preceding character is not whitespace
|
||||
let (remaining, _separator) = tag("--")(remaining)?;
|
||||
let (remaining, second_timestamp) = impl_inactive_timestamp(context, remaining, false)?;
|
||||
let (remaining, second_timestamp) = inactive_timestamp(context, remaining)?;
|
||||
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
|
@ -132,7 +132,6 @@ pub struct DiarySexp<'s> {
|
||||
pub source: &'s str,
|
||||
pub affiliated_keywords: AffiliatedKeywords<'s>,
|
||||
pub value: &'s str,
|
||||
pub post_blank: Option<&'s str>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -371,15 +370,11 @@ impl<'s> StandardProperties<'s> for DiarySexp<'s> {
|
||||
}
|
||||
|
||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||
None
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_post_blank(&self) -> PostBlank {
|
||||
self.post_blank
|
||||
.map(|text| text.lines().count())
|
||||
.unwrap_or(0)
|
||||
.try_into()
|
||||
.expect("Too much post-blank to fit into a PostBlank.")
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user