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 = "SlugOptions"))]
245pub struct Slug {
246 pub prefix: String,
248}
249
250#[derive(Clone, Debug, Default, Deserialize)]
252#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
253#[serde(default, rename_all = "camelCase")]
254#[cfg_attr(feature = "schema", schemars(rename = "ToMarkdownOptions"))]
255pub struct ToMarkdown {
256 pub document: bool,
258 pub newlines: bool,
260 pub checked: Option<String>,
262 pub unchecked: Option<String>,
264 pub quotes: Option<Vec<String>>,
267}
268
269#[derive(Clone, Debug, Default, Deserialize)]
272#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
273#[serde(default, rename_all = "camelCase")]
274#[cfg_attr(feature = "schema", schemars(rename = "RawOptions"))]
275pub struct Raw {
276 pub pass_through: Vec<String>,
279 pub tagfilter: bool,
281}
282
283#[derive(Clone, Debug, Default, Deserialize)]
286#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
287#[serde(default, rename_all = "camelCase")]
288#[cfg_attr(feature = "schema", schemars(rename = "FormatOptions"))]
289pub struct Format {
290 pub blanks: Vec<String>,
292 pub indent: Option<Indent>,
295 pub indent_initial: Option<bool>,
297}
298
299#[derive(Clone, Debug, Deserialize)]
301#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
302#[serde(untagged)]
303pub enum Indent {
304 Spaces(usize),
305 Text(String),
306}