From e5a5f71f9470c8c6602791a173660c8e6901c5c1 Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Mon, 18 Nov 2024 11:54:47 +0100 Subject: [PATCH] Add config option for pulldown-cmark math --- components/config/src/config/markup.rs | 3 +++ components/markdown/src/markdown.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/components/config/src/config/markup.rs b/components/config/src/config/markup.rs index 9ea5b2337b..f0a0647be1 100644 --- a/components/config/src/config/markup.rs +++ b/components/config/src/config/markup.rs @@ -45,6 +45,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 to enable latex math rendering + pub math: 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. @@ -208,6 +210,7 @@ impl Default for Markdown { external_links_no_follow: false, external_links_no_referrer: false, smart_punctuation: false, + math: false, bottom_footnotes: false, extra_syntaxes_and_themes: vec![], extra_syntax_set: None, diff --git a/components/markdown/src/markdown.rs b/components/markdown/src/markdown.rs index bcbca47999..9b1151f99e 100644 --- a/components/markdown/src/markdown.rs +++ b/components/markdown/src/markdown.rs @@ -439,6 +439,9 @@ pub fn markdown_to_html( if context.config.markdown.smart_punctuation { opts.insert(Options::ENABLE_SMART_PUNCTUATION); } + if context.config.markdown.math { + opts.insert(Options::ENABLE_MATH); + } // we reverse their order so we can pop them easily in order let mut html_shortcodes: Vec<_> = html_shortcodes.into_iter().rev().collect();