Add plain list items.

main
Tom Alexander 6 months ago
parent 62ffc76376
commit bfc9e3ed80
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -1,6 +1,6 @@
{@select key=list_type}
{@eq value="unordered"}<li></li>{/eq}
{@eq value="ordered"}<li></li>{/eq}
{@eq value="descriptive"}<dt></dt><dd></dd>{/eq}
{@eq value="unordered"}<li>{#.children}{>element/}{/.children}</li>{/eq}
{@eq value="ordered"}<li>{#.children}{>element/}{/.children}</li>{/eq}
{@eq value="descriptive"}<dt>{#.tag}{>object/}{/.tag}</dt><dd>{#.children}{>element/}{/.children}</dd>{/eq}
{@none}{!TODO: make this panic!}ERROR: Unrecognized list type {.list_type}.{/none}
{/select}

@ -6,10 +6,16 @@ use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IPlainListItem;
use super::RenderElement;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "plain_list_item")]
pub(crate) struct RenderPlainListItem {}
pub(crate) struct RenderPlainListItem {
tag: Vec<RenderObject>,
children: Vec<RenderElement>,
}
impl RenderPlainListItem {
pub(crate) fn new(
@ -18,6 +24,31 @@ impl RenderPlainListItem {
output_file: &Path,
original: &IPlainListItem,
) -> Result<RenderPlainListItem, CustomError> {
Ok(RenderPlainListItem {})
let tag = {
let mut ret = Vec::new();
for obj in original.tag.iter() {
ret.push(RenderObject::new(
config,
&output_directory,
&output_file,
obj,
)?);
}
ret
};
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(RenderElement::new(
config,
&output_directory,
&output_file,
obj,
)?);
}
ret
};
Ok(RenderPlainListItem { tag, children })
}
}

@ -1,15 +1,36 @@
use crate::error::CustomError;
use super::registry::Registry;
use super::IElement;
use super::IObject;
#[derive(Debug)]
pub(crate) struct IPlainListItem {}
pub(crate) struct IPlainListItem {
pub(crate) tag: Vec<IObject>,
pub(crate) children: Vec<IElement>,
}
impl IPlainListItem {
pub(crate) async fn new<'parse>(
registry: &mut Registry<'parse>,
plain_list_item: &organic::types::PlainListItem<'parse>,
) -> Result<IPlainListItem, CustomError> {
Ok(IPlainListItem {})
let tag = {
let mut ret = Vec::new();
for obj in plain_list_item.tag.iter() {
ret.push(IObject::new(registry, obj).await?);
}
ret
};
let children = {
let mut ret = Vec::new();
for elem in plain_list_item.children.iter() {
ret.push(IElement::new(registry, elem).await?);
}
ret
};
Ok(IPlainListItem { tag, children })
}
}

Loading…
Cancel
Save