diff --git a/src/compare/util.rs b/src/compare/util.rs index 1fa9daaa..e1df0db8 100644 --- a/src/compare/util.rs +++ b/src/compare/util.rs @@ -116,12 +116,10 @@ fn assert_bounds<'b, 's, S: StandardProperties<'s> + ?Sized>( if rust_begin_char_offset != begin || rust_end_char_offset != end { Err(format!("Rust contents bounds (in chars) ({rust_begin}, {rust_end}) do not match emacs contents bounds ({emacs_begin}, {emacs_end})", rust_begin = rust_begin_char_offset, rust_end = rust_end_char_offset, emacs_begin=begin, emacs_end=end))?; } - } else { - if standard_properties.contents_begin.is_some() - || standard_properties.contents_end.is_some() - { - Err(format!("Rust contents is None but emacs contents bounds are ({emacs_begin:?}, {emacs_end:?})", emacs_begin=standard_properties.contents_begin, emacs_end=standard_properties.contents_end))?; - } + } else if standard_properties.contents_begin.is_some() + || standard_properties.contents_end.is_some() + { + Err(format!("Rust contents is None but emacs contents bounds are ({emacs_begin:?}, {emacs_end:?})", emacs_begin=standard_properties.contents_begin, emacs_end=standard_properties.contents_end))?; } } diff --git a/src/parser/footnote_reference.rs b/src/parser/footnote_reference.rs index d09522b6..a2c5c599 100644 --- a/src/parser/footnote_reference.rs +++ b/src/parser/footnote_reference.rs @@ -82,6 +82,7 @@ fn anonymous_footnote<'b, 'g, 'r, 's>( FootnoteReference { source: source.into(), contents: Some(contents.into()), + post_blank: _trailing_whitespace.map(Into::<&str>::into), label: None, definition: children, }, @@ -130,6 +131,7 @@ fn inline_footnote<'b, 'g, 'r, 's>( FootnoteReference { source: source.into(), contents: Some(contents.into()), + post_blank: _trailing_whitespace.map(Into::<&str>::into), label: Some(label_contents.into()), definition: children, }, @@ -155,6 +157,7 @@ fn footnote_reference_only<'b, 'g, 'r, 's>( FootnoteReference { source: source.into(), contents: None, + post_blank: _trailing_whitespace.map(Into::<&str>::into), label: Some(label_contents.into()), definition: Vec::with_capacity(0), }, diff --git a/src/types/object.rs b/src/types/object.rs index df58910c..b14f83b4 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -193,6 +193,7 @@ pub struct ExportSnippet<'s> { pub struct FootnoteReference<'s> { pub source: &'s str, pub contents: Option<&'s str>, + pub post_blank: Option<&'s str>, pub label: Option<&'s str>, pub definition: Vec>, } @@ -736,7 +737,11 @@ impl<'s> StandardProperties<'s> for FootnoteReference<'s> { } fn get_post_blank<'b>(&'b 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.") } }