Implement citation.
This commit is contained in:
parent
ea000894f0
commit
9901e17437
@ -4,15 +4,15 @@ 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::Citation;
|
use crate::types::Citation;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct WasmCitation {
|
pub struct WasmCitation {
|
||||||
#[serde(flatten)]
|
pub(crate) style: Option<String>,
|
||||||
pub(crate) additional_properties: AdditionalProperties,
|
pub(crate) prefix: Option<Vec<WasmAstNode>>,
|
||||||
|
pub(crate) suffix: Option<Vec<WasmAstNode>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -21,7 +21,7 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::Citation(original) },
|
{ WasmAstNode::Citation(original) },
|
||||||
{ "TODO".into() },
|
{ "citation".into() },
|
||||||
{
|
{
|
||||||
let children = original
|
let children = original
|
||||||
.children
|
.children
|
||||||
@ -32,11 +32,39 @@ to_wasm!(
|
|||||||
.map(Into::<WasmAstNode>::into)
|
.map(Into::<WasmAstNode>::into)
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
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((
|
Ok((
|
||||||
children,
|
children,
|
||||||
WasmCitation {
|
WasmCitation {
|
||||||
additional_properties: AdditionalProperties::default(),
|
style: original.style.map(|s| s.to_owned()),
|
||||||
|
prefix: if prefix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(prefix)
|
||||||
|
},
|
||||||
|
suffix: if suffix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(suffix)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user