Implement footnote reference.

This commit is contained in:
Tom Alexander 2023-12-30 16:05:41 -05:00
parent 65ce116998
commit e0c0070a13
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -4,15 +4,16 @@ use serde::Serialize;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact; use crate::compare::ElispFact;
use crate::types::FootnoteReference; use crate::types::FootnoteReference;
use crate::types::FootnoteReferenceType;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct WasmFootnoteReference { pub struct WasmFootnoteReference {
#[serde(flatten)] pub(crate) label: Option<String>,
pub(crate) additional_properties: AdditionalProperties, #[serde(rename = "type")]
pub(crate) footnote_reference_type: String,
} }
to_wasm!( to_wasm!(
@ -21,12 +22,27 @@ to_wasm!(
original, original,
wasm_context, wasm_context,
{ WasmAstNode::FootnoteReference(original) }, { WasmAstNode::FootnoteReference(original) },
{ "TODO".into() }, { "footnote-reference".into() },
{ {
let children = original
.definition
.iter()
.map(|child| {
child
.to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode>::into)
})
.collect::<Result<Vec<_>, _>>()?;
Ok(( Ok((
Vec::new(), children,
WasmFootnoteReference { WasmFootnoteReference {
additional_properties: AdditionalProperties::default(), label: original.label.map(|s| s.to_owned()),
footnote_reference_type: match original.get_type() {
FootnoteReferenceType::Standard => "standard",
FootnoteReferenceType::Inline => "inline",
}
.to_owned(),
}, },
)) ))
} }