Populating document's children.
This commit is contained in:
parent
995b41e697
commit
67e5829fd9
@ -60,10 +60,11 @@ use super::verbatim::WasmVerbatim;
|
|||||||
use super::verse_block::WasmVerseBlock;
|
use super::verse_block::WasmVerseBlock;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
pub enum WasmAstNode<'s> {
|
pub enum WasmAstNode<'s> {
|
||||||
// Document Nodes
|
// Document Nodes
|
||||||
Document(WasmDocument<'s>),
|
Document(WasmDocument<'s>),
|
||||||
Heading(WasmHeadline<'s>),
|
Headline(WasmHeadline<'s>),
|
||||||
Section(WasmSection<'s>),
|
Section(WasmSection<'s>),
|
||||||
// Elements
|
// Elements
|
||||||
Paragraph(WasmParagraph<'s>),
|
Paragraph(WasmParagraph<'s>),
|
||||||
|
@ -33,16 +33,34 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let children = original
|
||||||
|
.zeroth_section
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode<'_>>::into)
|
||||||
|
})
|
||||||
|
.chain(original.children.iter().map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode<'_>>::into)
|
||||||
|
}))
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
// let children = original
|
// let children = original
|
||||||
// .children
|
// .children
|
||||||
// .iter()
|
// .iter()
|
||||||
// .map(|child| child.to_wasm(wasm_context.clone()))
|
// .map(|child| {
|
||||||
|
// child
|
||||||
|
// .to_wasm(wasm_context.clone())
|
||||||
|
// .map(Into::<WasmAstNode<'_>>::into)
|
||||||
|
// })
|
||||||
// .collect::<Result<Vec<_>, _>>()?;
|
// .collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
Ok(WasmDocument {
|
Ok(WasmDocument {
|
||||||
standard_properties,
|
standard_properties,
|
||||||
additional_properties,
|
additional_properties,
|
||||||
children: Vec::new(),
|
children,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use organic::types::Heading;
|
use organic::types::Heading;
|
||||||
use serde::Deserialize;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
use super::standard_properties::WasmStandardProperties;
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
@ -11,7 +11,7 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
|
|||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "ast_node")]
|
#[serde(tag = "ast_node")]
|
||||||
#[serde(rename = "org-data")]
|
#[serde(rename = "headline")]
|
||||||
pub(crate) struct WasmHeadline<'s> {
|
pub(crate) struct WasmHeadline<'s> {
|
||||||
standard_properties: WasmStandardProperties,
|
standard_properties: WasmStandardProperties,
|
||||||
children: Vec<()>,
|
children: Vec<()>,
|
||||||
@ -32,3 +32,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s> Into<WasmAstNode<'s>> for WasmHeadline<'s> {
|
||||||
|
fn into(self) -> WasmAstNode<'s> {
|
||||||
|
WasmAstNode::Headline(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -11,7 +11,8 @@ macro_rules! to_wasm {
|
|||||||
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
|
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
|
||||||
) -> Result<Self::Output, crate::error::CustomError> {
|
) -> Result<Self::Output, crate::error::CustomError> {
|
||||||
let $original = self;
|
let $original = self;
|
||||||
let $standard_properties = self.to_wasm_standard_properties($wasm_context)?;
|
let $standard_properties =
|
||||||
|
self.to_wasm_standard_properties($wasm_context.clone())?;
|
||||||
$fnbody
|
$fnbody
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use organic::types::Section;
|
use organic::types::Section;
|
||||||
use serde::Deserialize;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
use super::standard_properties::WasmStandardProperties;
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
@ -11,7 +11,7 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
|
|||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "ast_node")]
|
#[serde(tag = "ast_node")]
|
||||||
#[serde(rename = "org-data")]
|
#[serde(rename = "section")]
|
||||||
pub(crate) struct WasmSection<'s> {
|
pub(crate) struct WasmSection<'s> {
|
||||||
standard_properties: WasmStandardProperties,
|
standard_properties: WasmStandardProperties,
|
||||||
children: Vec<()>,
|
children: Vec<()>,
|
||||||
@ -32,3 +32,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s> Into<WasmAstNode<'s>> for WasmSection<'s> {
|
||||||
|
fn into(self) -> WasmAstNode<'s> {
|
||||||
|
WasmAstNode::Section(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user