diff --git a/src/configuration.rs b/src/configuration.rs
index 38af0a5..4f0281f 100644
--- a/src/configuration.rs
+++ b/src/configuration.rs
@@ -31,6 +31,11 @@ use alloc::{boxed::Box, fmt, string::String};
/// ```
#[allow(clippy::struct_excessive_bools)]
#[derive(Clone, Debug, Eq, PartialEq)]
+#[cfg_attr(
+ feature = "serde",
+ derive(serde::Serialize, serde::Deserialize),
+ serde(rename_all = "camelCase")
+)]
pub struct Constructs {
/// Attention.
///
@@ -459,15 +464,69 @@ impl Constructs {
///
/// // In French:
/// let enFrançais = CompileOptions {
-/// gfm_footnote_label: Some("Notes de bas de page".into()),
/// gfm_footnote_back_label: Some("Arrière".into()),
+/// gfm_footnote_label: Some("Notes de bas de page".into()),
/// ..CompileOptions::default()
/// };
/// # }
/// ```
#[allow(clippy::struct_excessive_bools)]
#[derive(Clone, Debug, Default)]
+#[cfg_attr(
+ feature = "serde",
+ derive(serde::Serialize, serde::Deserialize),
+ serde(default, rename_all = "camelCase")
+)]
pub struct CompileOptions {
+ /// Whether to allow all values in images.
+ ///
+ /// The default is `false`,
+ /// which lets `allow_dangerous_protocol` control protocol safety for
+ /// both links and images.
+ ///
+ /// Pass `true` to allow all values as `src` on images,
+ /// regardless of `allow_dangerous_protocol`.
+ /// This is safe because the
+ /// [HTML specification][whatwg-html-image-processing]
+ /// does not allow executable code in images.
+ ///
+ /// [whatwg-html-image-processing]: https://html.spec.whatwg.org/multipage/images.html#images-processing-model
+ ///
+ /// ## Examples
+ ///
+ /// ```
+ /// use markdown::{to_html_with_options, CompileOptions, Options};
+ /// # fn main() -> Result<(), markdown::message::Message> {
+ ///
+ /// // By default, some protocols in image sources are dropped:
+ /// assert_eq!(
+ /// to_html_with_options(
+ /// "",
+ /// &Options::default()
+ /// )?,
+ /// "
"
+ /// );
+ ///
+ /// // Turn `allow_any_img_src` on to allow all values as `src` on images.
+ /// // This is safe because browsers do not execute code in images.
+ /// assert_eq!(
+ /// to_html_with_options(
+ /// ")",
+ /// &Options {
+ /// compile: CompileOptions {
+ /// allow_any_img_src: true,
+ /// ..CompileOptions::default()
+ /// },
+ /// ..Options::default()
+ /// }
+ /// )?,
+ /// "
"
+ /// );
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub allow_any_img_src: bool,
+
/// Whether to allow (dangerous) HTML.
///
/// The default is `false`, which still parses the HTML according to
@@ -563,55 +622,6 @@ pub struct CompileOptions {
/// ```
pub allow_dangerous_protocol: bool,
- /// Whether to allow all values in images.
- ///
- /// The default is `false`,
- /// which lets `allow_dangerous_protocol` control protocol safety for
- /// both links and images.
- ///
- /// Pass `true` to allow all values as `src` on images,
- /// regardless of `allow_dangerous_protocol`.
- /// This is safe because the
- /// [HTML specification][whatwg-html-image-processing]
- /// does not allow executable code in images.
- ///
- /// [whatwg-html-image-processing]: https://html.spec.whatwg.org/multipage/images.html#images-processing-model
- ///
- /// ## Examples
- ///
- /// ```
- /// use markdown::{to_html_with_options, CompileOptions, Options};
- /// # fn main() -> Result<(), markdown::message::Message> {
- ///
- /// // By default, some protocols in image sources are dropped:
- /// assert_eq!(
- /// to_html_with_options(
- /// "",
- /// &Options::default()
- /// )?,
- /// "
"
- /// );
- ///
- /// // Turn `allow_any_img_src` on to allow all values as `src` on images.
- /// // This is safe because browsers do not execute code in images.
- /// assert_eq!(
- /// to_html_with_options(
- /// ")",
- /// &Options {
- /// compile: CompileOptions {
- /// allow_any_img_src: true,
- /// ..CompileOptions::default()
- /// },
- /// ..Options::default()
- /// }
- /// )?,
- /// "
"
- /// );
- /// # Ok(())
- /// # }
- /// ```
- pub allow_any_img_src: bool,
-
// To do: `doc_markdown` is broken.
#[allow(clippy::doc_markdown)]
/// Default line ending to use when compiling to HTML, for line endings not
@@ -658,16 +668,14 @@ pub struct CompileOptions {
/// ```
pub default_line_ending: LineEnding,
- /// Textual label to use for the footnotes section.
+ /// Textual label to describe the backreference back to footnote calls.
///
- /// The default value is `"Footnotes"`.
+ /// The default value is `"Back to content"`.
/// Change it when the markdown is not in English.
///
- /// This label is typically hidden visually (assuming a `sr-only` CSS class
- /// is defined that does that), and thus affects screen readers only.
- /// If you do have such a class, but want to show this section to everyone,
- /// pass different attributes with the `gfm_footnote_label_attributes`
- /// option.
+ /// This label is used in the `aria-label` attribute on each backreference
+ /// (the `↩` links).
+ /// It affects users of assistive technology.
///
/// ## Examples
///
@@ -675,7 +683,7 @@ pub struct CompileOptions {
/// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), markdown::message::Message> {
///
- /// // `"Footnotes"` is used by default:
+ /// // `"Back to content"` is used by default:
/// assert_eq!(
/// to_html_with_options(
/// "[^a]\n\n[^a]: b",
@@ -684,35 +692,46 @@ pub struct CompileOptions {
/// "
\n\n\n"
/// );
/// # Ok(())
/// # }
/// ```
- pub gfm_footnote_label: Option,
+ pub gfm_footnote_back_label: Option,
- /// HTML tag name to use for the footnote label element.
+ /// Prefix to use before the `id` attribute on footnotes to prevent them
+ /// from *clobbering*.
///
- /// The default value is `"h2"`.
- /// Change it to match your document structure.
+ /// The default is `"user-content-"`.
+ /// Pass `Some("".into())` for trusted markdown and when you are careful
+ /// with polyfilling.
+ /// You could pass a different prefix.
///
- /// This label is typically hidden visually (assuming a `sr-only` CSS class
- /// is defined that does that), and thus affects screen readers only.
- /// If you do have such a class, but want to show this section to everyone,
- /// pass different attributes with the `gfm_footnote_label_attributes`
- /// option.
+ /// DOM clobbering is this:
+ ///
+ /// ```html
+ ///
+ ///
+ /// ```
+ ///
+ /// The above example shows that elements are made available by browsers,
+ /// by their ID, on the `window` object.
+ /// This is a security risk because you might be expecting some other
+ /// variable at that place.
+ /// It can also break polyfills.
+ /// Using a prefix solves these problems.
///
/// ## Examples
///
@@ -720,7 +739,7 @@ pub struct CompileOptions {
/// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), markdown::message::Message> {
///
- /// // `"h2"` is used by default:
+ /// // `"user-content-"` is used by default:
/// assert_eq!(
/// to_html_with_options(
/// "[^a]\n\n[^a]: b",
@@ -729,24 +748,24 @@ pub struct CompileOptions {
/// "
\n\n\n"
/// );
/// # Ok(())
/// # }
/// ```
- pub gfm_footnote_label_tag_name: Option,
+ pub gfm_footnote_clobber_prefix: Option,
/// Attributes to use on the footnote label.
///
@@ -796,14 +815,16 @@ pub struct CompileOptions {
/// ```
pub gfm_footnote_label_attributes: Option,
- /// Textual label to describe the backreference back to footnote calls.
+ /// HTML tag name to use for the footnote label element.
///
- /// The default value is `"Back to content"`.
- /// Change it when the markdown is not in English.
+ /// The default value is `"h2"`.
+ /// Change it to match your document structure.
///
- /// This label is used in the `aria-label` attribute on each backreference
- /// (the `↩` links).
- /// It affects users of assistive technology.
+ /// This label is typically hidden visually (assuming a `sr-only` CSS class
+ /// is defined that does that), and thus affects screen readers only.
+ /// If you do have such a class, but want to show this section to everyone,
+ /// pass different attributes with the `gfm_footnote_label_attributes`
+ /// option.
///
/// ## Examples
///
@@ -811,7 +832,7 @@ pub struct CompileOptions {
/// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), markdown::message::Message> {
///
- /// // `"Back to content"` is used by default:
+ /// // `"h2"` is used by default:
/// assert_eq!(
/// to_html_with_options(
/// "[^a]\n\n[^a]: b",
@@ -820,46 +841,35 @@ pub struct CompileOptions {
/// "
\n\n\n"
/// );
/// # Ok(())
/// # }
/// ```
- pub gfm_footnote_back_label: Option,
+ pub gfm_footnote_label_tag_name: Option,
- /// Prefix to use before the `id` attribute on footnotes to prevent them
- /// from *clobbering*.
- ///
- /// The default is `"user-content-"`.
- /// Pass `Some("".into())` for trusted markdown and when you are careful
- /// with polyfilling.
- /// You could pass a different prefix.
- ///
- /// DOM clobbering is this:
+ /// Textual label to use for the footnotes section.
///
- /// ```html
- ///
- ///
- /// ```
+ /// The default value is `"Footnotes"`.
+ /// Change it when the markdown is not in English.
///
- /// The above example shows that elements are made available by browsers,
- /// by their ID, on the `window` object.
- /// This is a security risk because you might be expecting some other
- /// variable at that place.
- /// It can also break polyfills.
- /// Using a prefix solves these problems.
+ /// This label is typically hidden visually (assuming a `sr-only` CSS class
+ /// is defined that does that), and thus affects screen readers only.
+ /// If you do have such a class, but want to show this section to everyone,
+ /// pass different attributes with the `gfm_footnote_label_attributes`
+ /// option.
///
/// ## Examples
///
@@ -867,7 +877,7 @@ pub struct CompileOptions {
/// use markdown::{to_html_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), markdown::message::Message> {
///
- /// // `"user-content-"` is used by default:
+ /// // `"Footnotes"` is used by default:
/// assert_eq!(
/// to_html_with_options(
/// "[^a]\n\n[^a]: b",
@@ -876,24 +886,24 @@ pub struct CompileOptions {
/// "