use std::collections::{BTreeMap, HashMap};
use serde::Deserialize;
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(default, rename_all = "camelCase")]
#[cfg_attr(feature = "schema", schemars(rename = "StringifyOptions"))]
pub struct Stringify {
pub allow_dangerous_html: bool,
pub allow_dangerous_characters: bool,
pub allow_parse_errors: bool,
pub bogus_comments: bool,
pub close_empty_elements: bool,
pub close_self_closing: bool,
pub collapse_empty_attributes: bool,
pub omit_optional_tags: bool,
pub prefer_unquoted: bool,
pub quote: Option<String>,
pub quote_smart: bool,
pub space: Option<String>,
pub tight_attributes: bool,
pub tight_comma_separated_lists: bool,
pub tight_doctype: bool,
pub tight_self_closing: bool,
pub upper_doctype: bool,
pub voids: Option<Vec<String>>,
}
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(default, rename_all = "camelCase")]
#[cfg_attr(feature = "schema", schemars(rename = "ParseOptions"))]
pub struct Parse {
pub fragment: bool,
pub emit_parse_errors: bool,
pub verbose: bool,
}
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(default, rename_all = "camelCase")]
#[cfg_attr(feature = "schema", schemars(rename = "SanitizeOptions"))]
pub struct Sanitize {
pub allow_comments: Option<bool>,
pub allow_doctypes: Option<bool>,
pub ancestors: Option<HashMap<String, Vec<String>>>,
pub attributes: Option<HashMap<String, Vec<AttributeDefinition>>>,
pub clobber: Option<Vec<String>>,
pub clobber_prefix: Option<String>,
pub protocols: Option<HashMap<String, Vec<String>>>,
pub required: Option<HashMap<String, BTreeMap<String, Primitive>>>,
pub strip: Option<Vec<String>>,
pub tag_names: Option<Vec<String>>,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(untagged)]
pub enum AttributeDefinition {
Name(String),
Values(Vec<Primitive>),
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(untagged)]
pub enum Primitive {
Boolean(bool),
Number(f64),
String(String),
}
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(default, rename_all = "camelCase")]
#[cfg_attr(feature = "schema", schemars(rename = "HighlightOptions"))]
pub struct Highlight {
pub themes: Option<serde_json::Map<String, serde_json::Value>>,
pub theme: Option<String>,
pub default_language: Option<String>,
pub fallback_language: Option<String>,
pub color_replacements: BTreeMap<String, ColorReplacement>,
pub add_language_class: bool,
pub inline: Option<InlineCode>,
pub meta_property: Option<String>,
pub transformers: Vec<HighlightTransformer>,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(untagged)]
pub enum ColorReplacement {
Color(String),
Theme(BTreeMap<String, String>),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum InlineCode {
#[serde(rename = "tailing-curly-colon")]
TailingCurlyColon,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(untagged)]
pub enum HighlightTransformer {
Name(TransformerName),
Configured(ConfiguredTransformer),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "camelCase")]
pub enum TransformerName {
NotationDiff,
NotationFocus,
NotationHighlight,
NotationErrorLevel,
MetaHighlight,
RenderLineNumber,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(tag = "name", rename_all = "camelCase")]
pub enum ConfiguredTransformer {
#[serde(rename_all = "camelCase")]
NotationDiff {
class_line_add: Option<Classes>,
class_line_remove: Option<Classes>,
class_active_pre: Option<Classes>,
class_active_code: Option<Classes>,
},
#[serde(rename_all = "camelCase")]
NotationFocus {
class_active_line: Option<Classes>,
class_active_pre: Option<Classes>,
class_active_code: Option<Classes>,
},
#[serde(rename_all = "camelCase")]
NotationHighlight {
class_active_line: Option<Classes>,
class_active_pre: Option<Classes>,
class_active_code: Option<Classes>,
},
#[serde(rename_all = "camelCase")]
NotationErrorLevel {
class_map: Option<BTreeMap<String, Classes>>,
class_active_pre: Option<Classes>,
class_active_code: Option<Classes>,
},
#[serde(rename_all = "camelCase")]
MetaHighlight {
class_name: Option<Classes>,
#[serde(default)]
zero_indexed: bool,
},
#[serde(rename_all = "camelCase")]
RenderLineNumber {
class_line_number: Option<Classes>,
start: Option<usize>,
},
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(untagged)]
pub enum Classes {
One(String),
Many(Vec<String>),
}
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(default, rename_all = "camelCase")]
#[cfg_attr(feature = "schema", schemars(rename = "SlugOptions"))]
pub struct Slug {
pub prefix: String,
}
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(default, rename_all = "camelCase")]
#[cfg_attr(feature = "schema", schemars(rename = "ToMarkdownOptions"))]
pub struct ToMarkdown {
pub document: bool,
pub newlines: bool,
pub checked: Option<String>,
pub unchecked: Option<String>,
pub quotes: Option<Vec<String>>,
}
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(default, rename_all = "camelCase")]
#[cfg_attr(feature = "schema", schemars(rename = "RawOptions"))]
pub struct Raw {
pub pass_through: Vec<String>,
pub tagfilter: bool,
}
#[derive(Clone, Debug, Default, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(default, rename_all = "camelCase")]
#[cfg_attr(feature = "schema", schemars(rename = "FormatOptions"))]
pub struct Format {
pub blanks: Vec<String>,
pub indent: Option<Indent>,
pub indent_initial: Option<bool>,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(untagged)]
pub enum Indent {
Spaces(usize),
Text(String),
}