use std::path::Path; use serde::Serialize; use crate::config::Config; use crate::error::CustomError; use crate::intermediate::IPlainList; use super::plain_list_item::RenderPlainListItem; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "plain_list")] pub(crate) struct RenderPlainList { list_type: String, children: Vec, } impl RenderPlainList { pub(crate) fn new( config: &Config, output_directory: &Path, output_file: &Path, original: &IPlainList, ) -> Result { let list_type = match original.list_type { organic::types::PlainListType::Unordered => "unordered".to_owned(), organic::types::PlainListType::Ordered => "ordered".to_owned(), organic::types::PlainListType::Descriptive => "descriptive".to_owned(), }; let children = { let mut ret = Vec::new(); for obj in original.children.iter() { ret.push(RenderPlainListItem::new( config, output_directory, output_file, obj, )?); } ret }; Ok(RenderPlainList { list_type, children, }) } }