Add basic templates for plain list.
This commit is contained in:
@@ -36,6 +36,7 @@ mod org_macro;
|
||||
mod paragraph;
|
||||
mod plain_link;
|
||||
mod plain_list;
|
||||
mod plain_list_item;
|
||||
mod plain_text;
|
||||
mod planning;
|
||||
mod property_drawer;
|
||||
|
||||
@@ -6,10 +6,15 @@ 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 {}
|
||||
pub(crate) struct RenderPlainList {
|
||||
list_type: String,
|
||||
children: Vec<RenderPlainListItem>,
|
||||
}
|
||||
|
||||
impl RenderPlainList {
|
||||
pub(crate) fn new(
|
||||
@@ -18,6 +23,27 @@ impl RenderPlainList {
|
||||
output_file: &Path,
|
||||
original: &IPlainList,
|
||||
) -> Result<RenderPlainList, CustomError> {
|
||||
Ok(RenderPlainList {})
|
||||
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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
23
src/context/plain_list_item.rs
Normal file
23
src/context/plain_list_item.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IPlainListItem;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "plain_list_item")]
|
||||
pub(crate) struct RenderPlainListItem {}
|
||||
|
||||
impl RenderPlainListItem {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IPlainListItem,
|
||||
) -> Result<RenderPlainListItem, CustomError> {
|
||||
Ok(RenderPlainListItem {})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user