Implement the new fields for plain list.
clippy Build clippy has failed Details
rust-foreign-document-test Build rust-foreign-document-test has failed Details
rust-build Build rust-build has succeeded Details
rust-test Build rust-test has failed Details

This commit is contained in:
Tom Alexander 2023-12-15 15:55:36 -05:00
parent 022dda06eb
commit 7a4dc20dc9
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 13 additions and 3 deletions

View File

@ -153,6 +153,7 @@ where
let mut children = Vec::new();
let mut first_item_indentation: Option<IndentationLevel> = None;
let mut first_item_list_type: Option<PlainListType> = None;
let contents_begin = remaining;
let mut remaining = remaining;
// The final list item does not consume trailing blank lines (which instead get consumed by the list). We have three options here:
@ -196,7 +197,8 @@ where
)));
}
let (remaining, _trailing_ws) =
let contents = get_consumed(contents_begin, remaining);
let (remaining, post_blank) =
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining);
Ok((
@ -209,6 +211,8 @@ where
),
list_type: first_item_list_type.expect("Plain lists require at least one element."),
children: children.into_iter().map(|(_start, item)| item).collect(),
contents: Some(Into::<&str>::into(contents)),
post_blank: post_blank.map(Into::<&str>::into),
},
))
}

View File

@ -13,6 +13,8 @@ pub struct PlainList<'s> {
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub list_type: PlainListType,
pub children: Vec<PlainListItem<'s>>,
pub contents: Option<&'s str>, // TODO: Can contents ever be None?
pub post_blank: Option<&'s str>,
}
#[derive(Debug, Copy, Clone)]
@ -142,11 +144,15 @@ impl<'s> StandardProperties<'s> for PlainList<'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.")
}
}