1use std::collections::{BTreeMap, HashMap};
2
3use serde::Deserialize;
4
5#[derive(Clone, Debug, Default, Deserialize)]
7#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
8#[serde(default, rename_all = "camelCase")]
9#[cfg_attr(feature = "schema", schemars(rename = "StringifyOptions"))]
10pub struct Stringify {
11 pub allow_dangerous_html: bool,
13 pub allow_dangerous_characters: bool,
15 pub allow_parse_errors: bool,
17 pub bogus_comments: bool,
19 pub close_empty_elements: bool,
21 pub close_self_closing: bool,
23 pub collapse_empty_attributes: bool,
25 pub omit_optional_tags: bool,
27 pub prefer_unquoted: bool,
29 pub quote: Option<String>,
31 pub quote_smart: bool,
33 pub space: Option<String>,
35 pub tight_attributes: bool,
37 pub tight_comma_separated_lists: bool,
39 pub tight_doctype: bool,
41 pub tight_self_closing: bool,
43 pub upper_doctype: bool,
45 pub voids: Option<Vec<String>>,
47}
48
49#[derive(Clone, Debug, Default, Deserialize)]
51#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
52#[serde(default, rename_all = "camelCase")]
53#[cfg_attr(feature = "schema", schemars(rename = "ParseOptions"))]
54pub struct Parse {
55 pub fragment: bool,
57 pub emit_parse_errors: bool,
59 pub verbose: bool,
61}
62
63#[derive(Clone, Debug, Default, Deserialize)]
66#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
67#[serde(default, rename_all = "camelCase")]
68#[cfg_attr(feature = "schema", schemars(rename = "SanitizeOptions"))]
69pub struct Sanitize {
70 pub allow_comments: Option<bool>,
72 pub allow_doctypes: Option<bool>,
74 pub ancestors: Option<HashMap<String, Vec<String>>>,
76 pub attributes: Option<HashMap<String, Vec<AttributeDefinition>>>,
79 pub clobber: Option<Vec<String>>,
81 pub clobber_prefix: Option<String>,
83 pub protocols: Option<HashMap<String, Vec<String>>>,
85 pub required: Option<HashMap<String, BTreeMap<String, Primitive>>>,
87 pub strip: Option<Vec<String>>,
89 pub tag_names: Option<Vec<String>>,
91}
92
93#[derive(Clone, Debug, Deserialize)]
95#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
96#[serde(untagged)]
97pub enum AttributeDefinition {
98 Name(String),
99 Values(Vec<Primitive>),
100}
101
102#[derive(Clone, Debug, PartialEq, Deserialize)]
104#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
105#[serde(untagged)]
106pub enum Primitive {
107 Boolean(bool),
108 Number(f64),
109 String(String),
110}
111
112#[derive(Clone, Debug, Default, Deserialize)]
115#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
116#[serde(default, rename_all = "camelCase")]
117#[cfg_attr(feature = "schema", schemars(rename = "HighlightOptions"))]
118pub struct Highlight {
119 pub themes: Option<serde_json::Map<String, serde_json::Value>>,
121 pub theme: Option<String>,
123 pub default_language: Option<String>,
125 pub fallback_language: Option<String>,
127 pub color_replacements: BTreeMap<String, ColorReplacement>,
130 pub add_language_class: bool,
132 pub inline: Option<InlineCode>,
135 pub meta_property: Option<String>,
138 pub transformers: Vec<HighlightTransformer>,
140}
141
142#[derive(Clone, Debug, Deserialize)]
144#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
145#[serde(untagged)]
146pub enum ColorReplacement {
147 Color(String),
148 Theme(BTreeMap<String, String>),
149}
150
151#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
153#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
154pub enum InlineCode {
155 #[serde(rename = "tailing-curly-colon")]
156 TailingCurlyColon,
157}
158
159#[derive(Clone, Debug, Deserialize)]
161#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
162#[serde(untagged)]
163pub enum HighlightTransformer {
164 Name(TransformerName),
165 Configured(ConfiguredTransformer),
166}
167
168#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
170#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
171#[serde(rename_all = "camelCase")]
172pub enum TransformerName {
173 NotationDiff,
174 NotationFocus,
175 NotationHighlight,
176 NotationErrorLevel,
177 MetaHighlight,
178 RenderLineNumber,
179}
180
181#[derive(Clone, Debug, Deserialize)]
183#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
184#[serde(tag = "name", rename_all = "camelCase")]
185pub enum ConfiguredTransformer {
186 #[serde(rename_all = "camelCase")]
188 NotationDiff {
189 class_line_add: Option<Classes>,
190 class_line_remove: Option<Classes>,
191 class_active_pre: Option<Classes>,
192 class_active_code: Option<Classes>,
193 },
194 #[serde(rename_all = "camelCase")]
196 NotationFocus {
197 class_active_line: Option<Classes>,
198 class_active_pre: Option<Classes>,
199 class_active_code: Option<Classes>,
200 },
201 #[serde(rename_all = "camelCase")]
203 NotationHighlight {
204 class_active_line: Option<Classes>,
205 class_active_pre: Option<Classes>,
206 class_active_code: Option<Classes>,
207 },
208 #[serde(rename_all = "camelCase")]
210 NotationErrorLevel {
211 class_map: Option<BTreeMap<String, Classes>>,
212 class_active_pre: Option<Classes>,
213 class_active_code: Option<Classes>,
214 },
215 #[serde(rename_all = "camelCase")]
217 MetaHighlight {
218 class_name: Option<Classes>,
219 #[serde(default)]
220 zero_indexed: bool,
221 },
222 #[serde(rename_all = "camelCase")]
224 RenderLineNumber {
225 class_line_number: Option<Classes>,
226 start: Option<usize>,
227 },
228}
229
230#[derive(Clone, Debug, Deserialize)]
232#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
233#[serde(untagged)]
234pub enum Classes {
235 One(String),
236 Many(Vec<String>),
237}
238
239#[derive(Clone, Debug, Default, Deserialize)]
242#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
243#[serde(default, rename_all = "camelCase")]
244#[cfg_attr(feature = "schema", schemars(rename = "ExternalLinksOptions"))]
245pub struct ExternalLinks {
246 pub target: Option<String>,
248 pub rel: Option<Tokens>,
251 pub protocols: Option<Vec<String>>,
254 pub properties: Option<serde_json::Map<String, serde_json::Value>>,
256 pub content: Option<serde_json::Value>,
258 pub content_properties: Option<serde_json::Map<String, serde_json::Value>>,
260}
261
262#[derive(Clone, Debug, Deserialize)]
264#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
265#[serde(untagged)]
266pub enum Tokens {
267 One(String),
268 Many(Vec<String>),
269}
270
271#[derive(Clone, Debug, Default, Deserialize)]
274#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
275#[serde(default, rename_all = "camelCase")]
276#[cfg_attr(feature = "schema", schemars(rename = "KatexOptions"))]
277pub struct Katex {
278 pub output: Option<KatexOutput>,
280 pub leqno: bool,
282 pub fleqn: bool,
284 pub error_color: Option<String>,
286 pub macros: BTreeMap<String, String>,
288 pub min_rule_thickness: Option<f64>,
290 pub color_is_text_color: bool,
292 pub strict: Option<KatexStrict>,
295 pub trust: bool,
297 pub max_size: Option<f64>,
299 pub max_expand: Option<usize>,
301 pub global_group: bool,
303}
304
305#[derive(Clone, Copy, Debug, PartialEq, Deserialize)]
307#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
308#[serde(rename_all = "camelCase")]
309pub enum KatexOutput {
310 Html,
311 Mathml,
312 HtmlAndMathml,
313}
314
315#[derive(Clone, Debug, PartialEq, Deserialize)]
317#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
318#[serde(untagged)]
319pub enum KatexStrict {
320 Boolean(bool),
321 Mode(KatexStrictMode),
322}
323
324#[derive(Clone, Copy, Debug, PartialEq, Deserialize)]
326#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
327#[serde(rename_all = "camelCase")]
328pub enum KatexStrictMode {
329 Ignore,
330 Warn,
331 Error,
332}
333
334#[derive(Clone, Debug, Default, Deserialize)]
337#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
338#[serde(default, rename_all = "camelCase")]
339#[cfg_attr(feature = "schema", schemars(rename = "SlugOptions"))]
340pub struct Slug {
341 pub prefix: String,
343}
344
345#[derive(Clone, Debug, Default, Deserialize)]
347#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
348#[serde(default, rename_all = "camelCase")]
349#[cfg_attr(feature = "schema", schemars(rename = "ToMarkdownOptions"))]
350pub struct ToMarkdown {
351 pub document: bool,
353 pub newlines: bool,
355 pub checked: Option<String>,
357 pub unchecked: Option<String>,
359 pub quotes: Option<Vec<String>>,
362}
363
364#[derive(Clone, Debug, Default, Deserialize)]
367#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
368#[serde(default, rename_all = "camelCase")]
369#[cfg_attr(feature = "schema", schemars(rename = "RawOptions"))]
370pub struct Raw {
371 pub pass_through: Vec<String>,
374 pub tagfilter: bool,
376}
377
378#[derive(Clone, Debug, Default, Deserialize)]
381#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
382#[serde(default, rename_all = "camelCase")]
383#[cfg_attr(feature = "schema", schemars(rename = "FormatOptions"))]
384pub struct Format {
385 pub blanks: Vec<String>,
387 pub indent: Option<Indent>,
390 pub indent_initial: Option<bool>,
392}
393
394#[derive(Clone, Debug, Deserialize)]
396#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
397#[serde(untagged)]
398pub enum Indent {
399 Spaces(usize),
400 Text(String),
401}