Update intermediate phase for table groups.
This commit is contained in:
parent
7741e192f5
commit
fa2dd96f78
@ -59,6 +59,7 @@ mod subscript;
|
|||||||
mod superscript;
|
mod superscript;
|
||||||
mod table;
|
mod table;
|
||||||
mod table_cell;
|
mod table_cell;
|
||||||
|
mod table_group;
|
||||||
mod table_row;
|
mod table_row;
|
||||||
mod target;
|
mod target;
|
||||||
mod timestamp;
|
mod timestamp;
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
use super::macros::intermediate;
|
use super::macros::intermediate;
|
||||||
use super::table_row::ITableRow;
|
use super::table_row::ITableRow;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
|
use crate::intermediate::table_group::ITableGroup;
|
||||||
use organic::types::StandardProperties;
|
use organic::types::StandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct ITable {
|
pub(crate) struct ITable {
|
||||||
pub(crate) children: Vec<ITableRow>,
|
pub(crate) children: Vec<ITableGroup>,
|
||||||
pub(crate) post_blank: organic::types::PostBlank,
|
pub(crate) post_blank: organic::types::PostBlank,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,10 +22,34 @@ intermediate!(
|
|||||||
|
|
||||||
let sections = group_into_sections(&original.children);
|
let sections = group_into_sections(&original.children);
|
||||||
|
|
||||||
let children = {
|
let children = if sections.len() == 1 {
|
||||||
|
// If there is only one section, then it is a body.
|
||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
for obj in original.children.iter() {
|
for group in sections.into_iter() {
|
||||||
ret.push(ITableRow::new(intermediate_context.clone(), obj).await?);
|
let mut rows = Vec::new();
|
||||||
|
for obj in group.into_iter() {
|
||||||
|
rows.push(ITableRow::new(intermediate_context.clone(), obj).await?)
|
||||||
|
}
|
||||||
|
ret.push(ITableGroup::Body(rows));
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
} else {
|
||||||
|
// If there are more than one section, the first is a head and the rest are body.
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
let mut sections = sections.into_iter();
|
||||||
|
if let Some(group) = sections.next() {
|
||||||
|
let mut rows = Vec::new();
|
||||||
|
for obj in group.into_iter() {
|
||||||
|
rows.push(ITableRow::new(intermediate_context.clone(), obj).await?)
|
||||||
|
}
|
||||||
|
ret.push(ITableGroup::Head(rows));
|
||||||
|
}
|
||||||
|
for group in sections {
|
||||||
|
let mut rows = Vec::new();
|
||||||
|
for obj in group.into_iter() {
|
||||||
|
rows.push(ITableRow::new(intermediate_context.clone(), obj).await?)
|
||||||
|
}
|
||||||
|
ret.push(ITableGroup::Body(rows));
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
};
|
};
|
||||||
|
7
src/intermediate/table_group.rs
Normal file
7
src/intermediate/table_group.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
use super::ITableRow;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub(crate) enum ITableGroup {
|
||||||
|
Head(Vec<ITableRow>),
|
||||||
|
Body(Vec<ITableRow>),
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user