mrml_wasm/render/
mod.rs

1#![allow(clippy::empty_docs)]
2
3use std::borrow::Cow;
4use std::collections::HashMap;
5
6#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, tsify::Tsify)]
7#[serde(rename_all = "camelCase")]
8#[tsify(into_wasm_abi, from_wasm_abi)]
9/// Rendering options
10pub struct RenderOptions {
11    /// If disabled, the comments won't be kept in the result. Disabled by
12    /// default.
13    pub disable_comments: bool,
14    /// Base url of the server to fetch the social icons.
15    pub social_icon_origin: Option<String>,
16    /// Map of fonts that can be used.
17    pub fonts: HashMap<String, String>,
18}
19
20impl From<RenderOptions> for mrml::prelude::render::RenderOptions {
21    fn from(value: RenderOptions) -> Self {
22        Self {
23            disable_comments: value.disable_comments,
24            social_icon_origin: value.social_icon_origin.map(Cow::Owned),
25            fonts: value
26                .fonts
27                .into_iter()
28                .map(|(key, value)| (key, Cow::Owned(value)))
29                .collect(),
30        }
31    }
32}