Add conversion to WasmAstNode for wasm Objects.
This commit is contained in:
parent
7626a69fa1
commit
28ad4fd046
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmAngleLink<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::AngleLink(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmBold<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Bold(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmCitation<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Citation(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmCitationReference<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::CitationReference(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmCode<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Code(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmEntity<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Entity(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmExportSnippet<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::ExportSnippet(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmFootnoteReference<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::FootnoteReference(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmInlineBabelCall<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::InlineBabelCall(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmInlineSourceBlock<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::InlineSourceBlock(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmItalic<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Italic(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmLatexFragment<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::LatexFragment(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmLineBreak<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::LineBreak(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmOrgMacro<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::OrgMacro(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -22,9 +22,19 @@ to_wasm!(
|
|||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
standard_properties,
|
||||||
{
|
{
|
||||||
|
let children = original
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode<'_, '_>>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
Ok(WasmParagraph {
|
Ok(WasmParagraph {
|
||||||
standard_properties,
|
standard_properties,
|
||||||
children: Vec::new(),
|
children,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmPlainLink<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::PlainLink(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmPlainText<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::PlainText(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmRadioLink<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::RadioLink(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmRadioTarget<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::RadioTarget(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmRegularLink<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::RegularLink(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmStatisticsCookie<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::StatisticsCookie(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmStrikeThrough<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::StrikeThrough(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmSubscript<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Subscript(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmSuperscript<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Superscript(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmTarget<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Target(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmTimestamp<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Timestamp(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@ use super::macros::to_wasm;
|
|||||||
use super::WasmAstNode;
|
use super::WasmAstNode;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::types::Element;
|
use crate::types::Element;
|
||||||
|
use crate::types::Object;
|
||||||
|
|
||||||
pub trait ToWasm<'p> {
|
pub trait ToWasm<'p> {
|
||||||
type Output;
|
type Output;
|
||||||
@ -90,3 +91,64 @@ to_wasm!(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmAstNode<'s, 'p>,
|
||||||
|
Object<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
match original {
|
||||||
|
Object::Bold(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::Italic(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::Underline(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::StrikeThrough(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::Code(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::Verbatim(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::PlainText(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::RegularLink(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::RadioLink(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::RadioTarget(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::PlainLink(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::AngleLink(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::OrgMacro(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::Entity(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::LatexFragment(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::ExportSnippet(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::FootnoteReference(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::Citation(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::CitationReference(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::InlineBabelCall(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::InlineSourceBlock(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::LineBreak(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::Target(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::StatisticsCookie(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::Subscript(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
Object::Superscript(inner) => {
|
||||||
|
inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into)
|
||||||
|
}
|
||||||
|
Object::Timestamp(inner) => inner.to_wasm(wasm_context).map(Into::<WasmAstNode>::into),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmUnderline<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Underline(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,3 +28,9 @@ to_wasm!(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmVerbatim<'s, 'p> {
|
||||||
|
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||||
|
WasmAstNode::Verbatim(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user