63 lines
1.6 KiB
Rust
63 lines
1.6 KiB
Rust
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
use super::ast_node::WasmAstNode;
|
|
use super::macros::to_wasm;
|
|
use super::to_wasm::ToWasm;
|
|
use crate::types::CitationReference;
|
|
use crate::util::elisp_fact::ElispFact;
|
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct WasmCitationReference {
|
|
pub(crate) key: String,
|
|
pub(crate) prefix: Option<Vec<WasmAstNode>>,
|
|
pub(crate) suffix: Option<Vec<WasmAstNode>>,
|
|
}
|
|
|
|
to_wasm!(
|
|
WasmCitationReference,
|
|
CitationReference<'s>,
|
|
original,
|
|
wasm_context,
|
|
{ WasmAstNode::CitationReference(original) },
|
|
{ "citation-reference".into() },
|
|
{
|
|
let prefix = original
|
|
.prefix
|
|
.iter()
|
|
.map(|child| {
|
|
child
|
|
.to_wasm(wasm_context.clone())
|
|
.map(Into::<WasmAstNode>::into)
|
|
})
|
|
.collect::<Result<Vec<_>, _>>()?;
|
|
let suffix = original
|
|
.suffix
|
|
.iter()
|
|
.map(|child| {
|
|
child
|
|
.to_wasm(wasm_context.clone())
|
|
.map(Into::<WasmAstNode>::into)
|
|
})
|
|
.collect::<Result<Vec<_>, _>>()?;
|
|
|
|
Ok((
|
|
Vec::new(),
|
|
WasmCitationReference {
|
|
key: original.key.to_owned(),
|
|
prefix: if prefix.is_empty() {
|
|
None
|
|
} else {
|
|
Some(prefix)
|
|
},
|
|
suffix: if suffix.is_empty() {
|
|
None
|
|
} else {
|
|
Some(suffix)
|
|
},
|
|
},
|
|
))
|
|
}
|
|
);
|