From e0c0070a1318956ccb003f65d42e70e458161511 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 30 Dec 2023 16:05:41 -0500 Subject: [PATCH] Implement footnote reference. --- src/wasm/footnote_reference.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/wasm/footnote_reference.rs b/src/wasm/footnote_reference.rs index 6b023ae..8b1b2fa 100644 --- a/src/wasm/footnote_reference.rs +++ b/src/wasm/footnote_reference.rs @@ -4,15 +4,16 @@ use serde::Serialize; use super::ast_node::WasmAstNode; use super::macros::to_wasm; use super::to_wasm::ToWasm; -use super::AdditionalProperties; use crate::compare::ElispFact; use crate::types::FootnoteReference; +use crate::types::FootnoteReferenceType; use crate::wasm::to_wasm::ToWasmStandardProperties; #[derive(Debug, Serialize, Deserialize)] pub struct WasmFootnoteReference { - #[serde(flatten)] - pub(crate) additional_properties: AdditionalProperties, + pub(crate) label: Option, + #[serde(rename = "type")] + pub(crate) footnote_reference_type: String, } to_wasm!( @@ -21,12 +22,27 @@ to_wasm!( original, wasm_context, { WasmAstNode::FootnoteReference(original) }, - { "TODO".into() }, + { "footnote-reference".into() }, { + let children = original + .definition + .iter() + .map(|child| { + child + .to_wasm(wasm_context.clone()) + .map(Into::::into) + }) + .collect::, _>>()?; + Ok(( - Vec::new(), + children, 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(), }, )) }