Compare commits
4 Commits
4753f4c7c6
...
f141a4e186
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f141a4e186 | ||
![]() |
aba29df34c | ||
![]() |
87ce7d7432 | ||
![]() |
68dccd54b1 |
@ -46,16 +46,22 @@ pub(crate) fn citation<'b, 'g, 'r, 's>(
|
||||
let (remaining, prefix) =
|
||||
must_balance_bracket(opt(parser_with_context!(global_prefix)(context)))(remaining)?;
|
||||
|
||||
let contents_begin = remaining;
|
||||
let (remaining, references) =
|
||||
separated_list1(tag(";"), parser_with_context!(citation_reference)(context))(remaining)?;
|
||||
let contents_end = {
|
||||
let (rem, _) = opt(tag(";"))(remaining)?;
|
||||
rem
|
||||
};
|
||||
let (remaining, suffix) = must_balance_bracket(opt(map(
|
||||
tuple((tag(";"), parser_with_context!(global_suffix)(context))),
|
||||
|(_, suffix)| suffix,
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag("]")(remaining)?;
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
let contents = contents_begin.get_until(contents_end);
|
||||
Ok((
|
||||
remaining,
|
||||
Citation {
|
||||
@ -64,6 +70,8 @@ pub(crate) fn citation<'b, 'g, 'r, 's>(
|
||||
prefix: prefix.unwrap_or(Vec::new()),
|
||||
suffix: suffix.unwrap_or(Vec::new()),
|
||||
children: references,
|
||||
contents: Into::<&str>::into(contents),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ pub(crate) fn org_macro<'b, 'g, 'r, 's>(
|
||||
let (remaining, macro_args) = opt(parser_with_context!(org_macro_args)(context))(remaining)?;
|
||||
let (remaining, _) = tag("}}}")(remaining)?;
|
||||
let macro_value = get_consumed(input, remaining);
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
|
||||
let source = get_consumed(input, remaining);
|
||||
@ -47,6 +47,7 @@ pub(crate) fn org_macro<'b, 'g, 'r, 's>(
|
||||
.map(|arg| arg.into())
|
||||
.collect(),
|
||||
value: Into::<&str>::into(macro_value),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ pub(crate) fn radio_link<'b, 'g, 'r, 's>(
|
||||
let rematched_target = rematch_target(context, radio_target, input);
|
||||
if let Ok((remaining, rematched_target)) = rematched_target {
|
||||
let path = get_consumed(input, remaining);
|
||||
let (remaining, _) = space0(remaining)?;
|
||||
let (remaining, post_blank) = space0(remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
return Ok((
|
||||
remaining,
|
||||
@ -47,6 +47,11 @@ pub(crate) fn radio_link<'b, 'g, 'r, 's>(
|
||||
source: source.into(),
|
||||
children: rematched_target,
|
||||
path: path.into(),
|
||||
post_blank: if post_blank.len() > 0 {
|
||||
Some(Into::<&str>::into(post_blank))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
},
|
||||
));
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ fn diary_timestamp<'b, 'g, 'r, 's>(
|
||||
let (remaining, _) = tag("<%%(")(input)?;
|
||||
let (remaining, _body) = sexp(context, remaining)?;
|
||||
let (remaining, _) = tag(")>")(remaining)?;
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -85,6 +85,7 @@ fn diary_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: None,
|
||||
repeater: None,
|
||||
warning_delay: None,
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -159,7 +160,7 @@ fn active_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag(">")(remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -175,6 +176,7 @@ fn active_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: time.map(|(_, time)| time),
|
||||
repeater: repeater.map(|(_, repeater)| repeater),
|
||||
warning_delay: warning_delay.map(|(_, warning_delay)| warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -213,7 +215,7 @@ pub(crate) fn inactive_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag("]")(remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -229,6 +231,7 @@ pub(crate) fn inactive_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: time.map(|(_, time)| time),
|
||||
repeater: repeater.map(|(_, repeater)| repeater),
|
||||
warning_delay: warning_delay.map(|(_, warning_delay)| warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -246,7 +249,7 @@ fn active_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
let (remaining, _separator) = tag("--")(remaining)?;
|
||||
let (remaining, second_timestamp) = active_timestamp(context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -264,6 +267,7 @@ fn active_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
warning_delay: first_timestamp
|
||||
.warning_delay
|
||||
.or(second_timestamp.warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -302,7 +306,7 @@ fn active_time_range_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag(">")(remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -318,6 +322,7 @@ fn active_time_range_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: Some(second_time),
|
||||
repeater: repeater.map(|(_, repeater)| repeater),
|
||||
warning_delay: warning_delay.map(|(_, warning_delay)| warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -335,7 +340,7 @@ pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
let (remaining, _separator) = tag("--")(remaining)?;
|
||||
let (remaining, second_timestamp) = inactive_timestamp(context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -354,6 +359,7 @@ pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||
warning_delay: first_timestamp
|
||||
.warning_delay
|
||||
.or(second_timestamp.warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -392,7 +398,7 @@ pub(crate) fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
|
||||
)))(remaining)?;
|
||||
let (remaining, _) = tag("]")(remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
@ -408,6 +414,7 @@ pub(crate) fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
|
||||
end_time: Some(second_time),
|
||||
repeater: repeater.map(|(_, repeater)| repeater),
|
||||
warning_delay: warning_delay.map(|(_, warning_delay)| warning_delay),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ pub struct RadioTarget<'s> {
|
||||
pub struct RadioLink<'s> {
|
||||
pub source: &'s str,
|
||||
pub path: &'s str,
|
||||
pub post_blank: Option<&'s str>,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
@ -176,6 +177,7 @@ pub struct OrgMacro<'s> {
|
||||
pub args: Vec<&'s str>,
|
||||
|
||||
pub value: &'s str,
|
||||
pub post_blank: Option<&'s str>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -222,6 +224,8 @@ pub struct Citation<'s> {
|
||||
pub prefix: Vec<Object<'s>>,
|
||||
pub suffix: Vec<Object<'s>>,
|
||||
pub children: Vec<CitationReference<'s>>,
|
||||
pub contents: &'s str,
|
||||
pub post_blank: Option<&'s str>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -298,6 +302,7 @@ pub struct Timestamp<'s> {
|
||||
pub end_time: Option<Time<'s>>,
|
||||
pub repeater: Option<Repeater>,
|
||||
pub warning_delay: Option<WarningDelay>,
|
||||
pub post_blank: Option<&'s str>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -671,11 +676,15 @@ impl<'s> StandardProperties<'s> for RadioLink<'s> {
|
||||
}
|
||||
|
||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||
todo!()
|
||||
Some(self.path)
|
||||
}
|
||||
|
||||
fn get_post_blank(&self) -> PostBlank {
|
||||
todo!()
|
||||
self.post_blank
|
||||
.map(|post_blank| post_blank.chars().count())
|
||||
.unwrap_or(0)
|
||||
.try_into()
|
||||
.expect("Too much post-blank to fit into a PostBlank.")
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,11 +748,15 @@ impl<'s> StandardProperties<'s> for OrgMacro<'s> {
|
||||
}
|
||||
|
||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||
todo!()
|
||||
None
|
||||
}
|
||||
|
||||
fn get_post_blank(&self) -> PostBlank {
|
||||
todo!()
|
||||
self.post_blank
|
||||
.map(|text| text.chars().count())
|
||||
.unwrap_or(0)
|
||||
.try_into()
|
||||
.expect("Too much post-blank to fit into a PostBlank.")
|
||||
}
|
||||
}
|
||||
|
||||
@ -821,11 +834,15 @@ impl<'s> StandardProperties<'s> for Citation<'s> {
|
||||
}
|
||||
|
||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||
todo!()
|
||||
Some(self.contents)
|
||||
}
|
||||
|
||||
fn get_post_blank(&self) -> PostBlank {
|
||||
todo!()
|
||||
self.post_blank
|
||||
.map(|text| text.chars().count())
|
||||
.unwrap_or(0)
|
||||
.try_into()
|
||||
.expect("Too much post-blank to fit into a PostBlank.")
|
||||
}
|
||||
}
|
||||
|
||||
@ -835,11 +852,11 @@ impl<'s> StandardProperties<'s> for CitationReference<'s> {
|
||||
}
|
||||
|
||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||
todo!()
|
||||
None
|
||||
}
|
||||
|
||||
fn get_post_blank(&self) -> PostBlank {
|
||||
todo!()
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
@ -959,11 +976,15 @@ impl<'s> StandardProperties<'s> for Timestamp<'s> {
|
||||
}
|
||||
|
||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||
todo!()
|
||||
None
|
||||
}
|
||||
|
||||
fn get_post_blank(&self) -> PostBlank {
|
||||
todo!()
|
||||
self.post_blank
|
||||
.map(|text| text.chars().count())
|
||||
.unwrap_or(0)
|
||||
.try_into()
|
||||
.expect("Too much post-blank to fit into a PostBlank.")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user