Compare commits

...

3 Commits

Author SHA1 Message Date
Tom Alexander
13c62bf29f
Implement the new fields for angle link.
Some checks failed
rust-foreign-document-test Build rust-foreign-document-test has failed
rust-build Build rust-build has succeeded
rust-test Build rust-test has failed
clippy Build clippy has failed
2023-12-11 13:00:43 -05:00
Tom Alexander
670209e9fc
Fix post blank for comment. 2023-12-11 12:58:05 -05:00
Tom Alexander
4af0d3141f
Implement the new fields for statistics cookie. 2023-12-11 12:51:07 -05:00
5 changed files with 28 additions and 9 deletions

View File

@ -47,7 +47,7 @@ pub(crate) fn angle_link<'b, 'g, 'r, 's>(
parser_with_context!(parse_angle_link)(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);
Ok((
@ -59,6 +59,7 @@ pub(crate) fn angle_link<'b, 'g, 'r, 's>(
raw_link: raw_link.into(),
search_option: parsed_link.search_option,
application: parsed_link.application,
post_blank: post_blank.map(Into::<&str>::into),
},
))
}

View File

@ -46,7 +46,7 @@ pub(crate) fn comment<'b, 'g, 'r, 's>(
let (remaining, mut remaining_lines) =
many0(preceded(not(exit_matcher), comment_line_matcher))(remaining)?;
let (remaining, _trailing_ws) =
let (remaining, post_blank) =
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining);
let mut value = Vec::with_capacity(remaining_lines.len() + 1);
@ -67,6 +67,7 @@ pub(crate) fn comment<'b, 'g, 'r, 's>(
Comment {
source: source.into(),
value,
post_blank: post_blank.map(Into::<&str>::into),
},
))
}

View File

@ -40,7 +40,7 @@ fn percent_statistics_cookie<'b, 'g, 'r, 's>(
tag("%]"),
)))(input)?;
let 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);
Ok((
@ -48,6 +48,7 @@ fn percent_statistics_cookie<'b, 'g, 'r, 's>(
StatisticsCookie {
source: source.into(),
value: value.into(),
post_blank: post_blank.map(Into::<&str>::into),
},
))
}
@ -68,7 +69,7 @@ fn fraction_statistics_cookie<'b, 'g, 'r, 's>(
tag("]"),
)))(input)?;
let 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);
Ok((
@ -76,6 +77,7 @@ fn fraction_statistics_cookie<'b, 'g, 'r, 's>(
StatisticsCookie {
source: source.into(),
value: value.into(),
post_blank: post_blank.map(Into::<&str>::into),
},
))
}

View File

@ -35,6 +35,7 @@ pub struct Paragraph<'s> {
pub struct Comment<'s> {
pub source: &'s str,
pub value: Vec<&'s str>,
pub post_blank: Option<&'s str>,
}
#[derive(Debug)]
@ -242,7 +243,11 @@ impl<'s> StandardProperties<'s> for Comment<'s> {
}
fn get_post_blank(&self) -> PostBlank {
0
self.post_blank
.map(|text| text.lines().count())
.unwrap_or(0)
.try_into()
.expect("Too much post-blank to fit into a PostBlank.")
}
}

View File

@ -157,6 +157,7 @@ pub struct AngleLink<'s> {
/// This does not take into account the post-processing that you would get from the upstream emacs org-mode AST. Use `get_search_option` for an equivalent value.
pub search_option: Option<&'s str>,
pub application: Option<&'s str>,
pub post_blank: Option<&'s str>,
}
#[derive(Debug)]
@ -263,6 +264,7 @@ pub struct Target<'s> {
pub struct StatisticsCookie<'s> {
pub source: &'s str,
pub value: &'s str,
pub post_blank: Option<&'s str>,
}
#[derive(Debug)]
@ -714,11 +716,15 @@ impl<'s> StandardProperties<'s> for AngleLink<'s> {
}
fn get_contents<'b>(&'b self) -> Option<&'s str> {
todo!()
None
}
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.")
}
}
@ -894,11 +900,15 @@ impl<'s> StandardProperties<'s> for StatisticsCookie<'s> {
}
fn get_contents<'b>(&'b self) -> Option<&'s str> {
todo!()
None
}
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.")
}
}