Files
organic/src/wasm/footnote_reference.rs

50 lines
1.4 KiB
Rust
Raw Normal View History

use serde::Deserialize;
use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
2023-12-30 22:02:43 -05:00
use crate::util::elisp_fact::ElispFact;
use crate::types::FootnoteReference;
2023-12-30 16:05:41 -05:00
use crate::types::FootnoteReferenceType;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
2023-12-29 12:49:43 -05:00
pub struct WasmFootnoteReference {
2023-12-30 16:05:41 -05:00
pub(crate) label: Option<String>,
#[serde(rename = "type")]
pub(crate) footnote_reference_type: String,
}
to_wasm!(
2023-12-29 12:49:43 -05:00
WasmFootnoteReference,
2023-12-25 11:51:39 -05:00
FootnoteReference<'s>,
2023-12-25 12:32:35 -05:00
original,
wasm_context,
{ WasmAstNode::FootnoteReference(original) },
2023-12-30 16:05:41 -05:00
{ "footnote-reference".into() },
{
2023-12-30 16:05:41 -05:00
let children = original
.definition
.iter()
.map(|child| {
child
.to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode>::into)
})
.collect::<Result<Vec<_>, _>>()?;
Ok((
2023-12-30 16:05:41 -05:00
children,
WasmFootnoteReference {
2023-12-30 16:05:41 -05:00
label: original.label.map(|s| s.to_owned()),
footnote_reference_type: match original.get_type() {
FootnoteReferenceType::Standard => "standard",
FootnoteReferenceType::Inline => "inline",
}
.to_owned(),
},
))
}
);