Merge branch 'table'

This commit is contained in:
Tom Alexander 2023-10-31 20:38:36 -04:00
commit e8963e107b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
11 changed files with 182 additions and 6 deletions

View File

@ -1 +1 @@
!!!!!!!! table
<table>{#.children}{>table_row/}{/.children}</table>

View File

@ -0,0 +1 @@
<td>{#.children}{>object/}{/.children}</td>

View File

@ -0,0 +1 @@
<tr>{#.children}{>table_cell/}{/.children}</tr>

View File

@ -54,6 +54,8 @@ mod strike_through;
mod subscript;
mod superscript;
mod table;
mod table_cell;
mod table_row;
mod target;
mod timestamp;
mod underline;

View File

@ -6,11 +6,37 @@ use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ITable;
use super::macros::rnoop;
use super::macros::render;
use super::table_row::RenderTableRow;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "table")]
pub(crate) struct RenderTable {}
pub(crate) struct RenderTable {
children: Vec<RenderTableRow>,
}
rnoop!(RenderTable, ITable);
render!(
RenderTable,
ITable,
original,
config,
output_directory,
output_file,
{
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(RenderTableRow::new(
config,
output_directory,
output_file,
obj,
)?);
}
ret
};
Ok(RenderTable { children })
}
);

42
src/context/table_cell.rs Normal file
View File

@ -0,0 +1,42 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ITableCell;
use super::macros::render;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "table_cell")]
pub(crate) struct RenderTableCell {
children: Vec<RenderObject>,
}
render!(
RenderTableCell,
ITableCell,
original,
config,
output_directory,
output_file,
{
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(RenderObject::new(
config,
output_directory,
output_file,
obj,
)?);
}
ret
};
Ok(RenderTableCell { children })
}
);

42
src/context/table_row.rs Normal file
View File

@ -0,0 +1,42 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ITableRow;
use super::macros::render;
use super::table_cell::RenderTableCell;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "table_row")]
pub(crate) struct RenderTableRow {
children: Vec<RenderTableCell>,
}
render!(
RenderTableRow,
ITableRow,
original,
config,
output_directory,
output_file,
{
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(RenderTableCell::new(
config,
output_directory,
output_file,
obj,
)?);
}
ret
};
Ok(RenderTableRow { children })
}
);

View File

@ -56,6 +56,8 @@ mod strike_through;
mod subscript;
mod superscript;
mod table;
mod table_cell;
mod table_row;
mod target;
mod timestamp;
mod underline;
@ -119,6 +121,8 @@ pub(crate) use strike_through::IStrikeThrough;
pub(crate) use subscript::ISubscript;
pub(crate) use superscript::ISuperscript;
pub(crate) use table::ITable;
pub(crate) use table_cell::ITableCell;
pub(crate) use table_row::ITableRow;
pub(crate) use target::ITarget;
pub(crate) use timestamp::ITimestamp;
pub(crate) use underline::IUnderline;

View File

@ -1,5 +1,21 @@
use super::macros::inoop;
use super::macros::intermediate;
use super::table_row::ITableRow;
use crate::error::CustomError;
inoop!(ITable, Table);
#[derive(Debug, Clone)]
pub(crate) struct ITable {
pub(crate) children: Vec<ITableRow>,
}
intermediate!(ITable, Table, original, registry, {
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(ITableRow::new(registry.clone(), obj).await?);
}
ret
};
Ok(ITable { children })
});

View File

@ -0,0 +1,21 @@
use super::macros::intermediate;
use super::IObject;
use crate::error::CustomError;
#[derive(Debug, Clone)]
pub(crate) struct ITableCell {
pub(crate) children: Vec<IObject>,
}
intermediate!(ITableCell, TableCell, original, registry, {
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(IObject::new(registry.clone(), obj).await?);
}
ret
};
Ok(ITableCell { children })
});

View File

@ -0,0 +1,21 @@
use super::macros::intermediate;
use super::table_cell::ITableCell;
use crate::error::CustomError;
#[derive(Debug, Clone)]
pub(crate) struct ITableRow {
pub(crate) children: Vec<ITableCell>,
}
intermediate!(ITableRow, TableRow, original, registry, {
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(ITableCell::new(registry.clone(), obj).await?);
}
ret
};
Ok(ITableRow { children })
});