use serde::Deserialize; use serde::Serialize; use super::ast_node::WasmAstNode; use super::macros::to_wasm; use super::src_block::WasmNumberLines; use super::src_block::WasmNumberLinesWrapper; use super::src_block::WasmRetainLabels; use super::to_wasm::ToWasm; use super::AdditionalProperties; use crate::types::CharOffsetInLine; use crate::types::ExampleBlock; use crate::types::GetAffiliatedKeywords; use crate::types::RetainLabels; use crate::types::SwitchNumberLines; use crate::util::elisp_fact::ElispFact; use crate::wasm::to_wasm::ToWasmStandardProperties; #[derive(Debug, Serialize, Deserialize)] pub struct WasmExampleBlock { #[serde(flatten)] pub(crate) additional_properties: AdditionalProperties, pub(crate) value: String, pub(crate) switches: Option, #[serde(rename = "number-lines")] pub(crate) number_lines: Option, #[serde(rename = "preserve-indent")] pub(crate) preserve_indent: Option, #[serde(rename = "retain-labels")] pub(crate) retain_labels: WasmRetainLabels, #[serde(rename = "use-labels")] pub(crate) use_labels: bool, #[serde(rename = "label-fmt")] pub(crate) label_format: Option, } to_wasm!( WasmExampleBlock, ExampleBlock<'s>, original, wasm_context, { WasmAstNode::ExampleBlock(original) }, { "example-block".into() }, { let additional_properties = original .get_affiliated_keywords() .to_wasm(wasm_context.clone())?; Ok(( Vec::new(), WasmExampleBlock { additional_properties, value: original.get_value().into_owned(), switches: original.switches.map(|s| s.to_owned()), number_lines: match original.number_lines { None => None, Some(SwitchNumberLines::New(n)) => Some(WasmNumberLinesWrapper { inner: WasmNumberLines::New(n), }), Some(SwitchNumberLines::Continued(n)) => Some(WasmNumberLinesWrapper { inner: WasmNumberLines::Continued(n), }), }, preserve_indent: original.preserve_indent, retain_labels: match original.retain_labels { RetainLabels::No => WasmRetainLabels::YesNo(false), RetainLabels::Yes => WasmRetainLabels::YesNo(true), RetainLabels::Keep(n) => WasmRetainLabels::Keep(n), }, use_labels: original.use_labels, label_format: original.label_format.map(|s| s.to_owned()), }, )) } );