Implement the new fields for paragraph.
This commit is contained in:
@@ -25,6 +25,8 @@ use crate::error::Res;
|
||||
#[derive(Debug)]
|
||||
pub struct Paragraph<'s> {
|
||||
pub source: &'s str,
|
||||
pub contents: Option<&'s str>,
|
||||
pub post_blank: Option<&'s str>,
|
||||
pub affiliated_keywords: AffiliatedKeywords<'s>,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
@@ -189,6 +191,8 @@ impl<'s> Paragraph<'s> {
|
||||
pub(crate) fn of_text(source: &'s str, body: &'s str) -> Self {
|
||||
Paragraph {
|
||||
source,
|
||||
contents: None, // TODO
|
||||
post_blank: None, // TODO
|
||||
affiliated_keywords: AffiliatedKeywords::default(),
|
||||
children: vec![Object::PlainText(PlainText { source: body })],
|
||||
}
|
||||
@@ -201,11 +205,15 @@ impl<'s> StandardProperties<'s> for Paragraph<'s> {
|
||||
}
|
||||
|
||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||
todo!()
|
||||
self.contents
|
||||
}
|
||||
|
||||
fn get_post_blank(&self) -> PostBlank {
|
||||
todo!()
|
||||
self.post_blank
|
||||
.map(|text| text.lines().count())
|
||||
.unwrap_or(0)
|
||||
.try_into()
|
||||
.expect("Too much post-blank to fit into a PostBlank.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user