diff --git a/CHANGELOG.md b/CHANGELOG.md index 19123301d3..40b7f12144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Exclude paginated pages in sitemap by default - Allow treating a missing highlight language as error - Handle more editors with change detection in `zola serve` +- Add optional parsing of Markdown definition lists ## 0.19.2 (2024-08-15) diff --git a/components/config/src/config/markup.rs b/components/config/src/config/markup.rs index 318524b24f..398ef8a3b4 100644 --- a/components/config/src/config/markup.rs +++ b/components/config/src/config/markup.rs @@ -47,6 +47,8 @@ pub struct Markdown { pub external_links_no_referrer: bool, /// Whether smart punctuation is enabled (changing quotes, dashes, dots etc in their typographic form) pub smart_punctuation: bool, + /// Whether parsing of definition lists is enabled + pub definition_list: bool, /// Whether footnotes are rendered at the bottom in the style of GitHub. pub bottom_footnotes: bool, /// A list of directories to search for additional `.sublime-syntax` and `.tmTheme` files in. @@ -227,6 +229,7 @@ impl Default for Markdown { external_links_no_follow: false, external_links_no_referrer: false, smart_punctuation: false, + definition_list: false, bottom_footnotes: false, extra_syntaxes_and_themes: vec![], extra_syntax_set: None, diff --git a/components/libs/Cargo.toml b/components/libs/Cargo.toml index ea3c82463c..ae6ba8e4a6 100644 --- a/components/libs/Cargo.toml +++ b/components/libs/Cargo.toml @@ -21,7 +21,7 @@ nom-bibtex = "0.5" num-format = "0.4" once_cell = "1" percent-encoding = "2" -pulldown-cmark = { version = "0.11", default-features = false, features = ["html", "simd"] } +pulldown-cmark = { version = "0.12.2", default-features = false, features = ["html", "simd"] } pulldown-cmark-escape = { version = "0.11", default-features = false } quickxml_to_serde = "0.6" rayon = "1" diff --git a/components/markdown/src/markdown.rs b/components/markdown/src/markdown.rs index 04f34475c3..bd69efa93e 100644 --- a/components/markdown/src/markdown.rs +++ b/components/markdown/src/markdown.rs @@ -440,6 +440,9 @@ pub fn markdown_to_html( if context.config.markdown.smart_punctuation { opts.insert(Options::ENABLE_SMART_PUNCTUATION); } + if context.config.markdown.definition_list { + opts.insert(Options::ENABLE_DEFINITION_LIST); + } // we reverse their order so we can pop them easily in order let mut html_shortcodes: Vec<_> = html_shortcodes.into_iter().rev().collect(); diff --git a/components/markdown/tests/markdown.rs b/components/markdown/tests/markdown.rs index 089bcc3aae..6797b8e6f6 100644 --- a/components/markdown/tests/markdown.rs +++ b/components/markdown/tests/markdown.rs @@ -152,6 +152,18 @@ fn can_use_smart_punctuation() { insta::assert_snapshot!(body); } +#[test] +fn can_use_definition_list() { + let mut config = Config::default_for_test(); + config.markdown.definition_list = true; + let content = r#" +term +: definition + "#; + let body = common::render_with_config(content, config).unwrap().body; + insta::assert_snapshot!(body); +} + #[test] fn can_use_external_links_class() { let mut config = Config::default_for_test(); diff --git a/components/markdown/tests/snapshots/markdown__can_use_definition_list.snap b/components/markdown/tests/snapshots/markdown__can_use_definition_list.snap new file mode 100644 index 0000000000..eaa5c1e7e5 --- /dev/null +++ b/components/markdown/tests/snapshots/markdown__can_use_definition_list.snap @@ -0,0 +1,8 @@ +--- +source: components/markdown/tests/markdown.rs +expression: body +--- +
+
term
+
definition
+
diff --git a/docs/content/documentation/getting-started/configuration.md b/docs/content/documentation/getting-started/configuration.md index 5b83712db2..51c4ad63e0 100644 --- a/docs/content/documentation/getting-started/configuration.md +++ b/docs/content/documentation/getting-started/configuration.md @@ -145,6 +145,9 @@ external_links_no_referrer = false # For example, `...` into `…`, `"quote"` into `“curly”` etc smart_punctuation = false +# Whether parsing of definition lists is enabled +definition_list = false + # Whether to set decoding="async" and loading="lazy" for all images # When turned on, the alt text must be plain text. # For example, `![xx](...)` is ok but `![*x*x](...)` isn’t ok