Enable math extension

This ensures LaTeX/MathJax blocks don't get mangled as seen in
https://github.com/zoni/obsidian-export/issues/14.
This commit is contained in:
Nick Groenen 2024-08-04 20:38:45 +02:00
parent 6d0e693ed7
commit e2ef435f04
No known key found for this signature in database
GPG Key ID: 4F0AD019928AE098
7 changed files with 33 additions and 5 deletions

1
changelog.d/14.breaking.md Symbolic link
View File

@ -0,0 +1 @@
252.breaking.md

4
changelog.d/14.fix.md Normal file
View File

@ -0,0 +1,4 @@
Don't escape square brackets in math expressions
The upgrade to [pulldown-cmark](https://crates.io/crates/pulldown-cmark) 0.11 (see Backwards-incompatible Changes) includes official support for LaTeX-style math expressions.
With the markdown parser supporting this syntax natively, math expressions are now processed correctly without edge-cases.

1
changelog.d/252.fix.md Symbolic link
View File

@ -0,0 +1 @@
14.fix.md

1
changelog.d/259.breaking.md Symbolic link
View File

@ -0,0 +1 @@
252.breaking.md

View File

@ -483,11 +483,11 @@ impl<'a> Exporter<'a> {
let frontmatter = let frontmatter =
frontmatter_from_str(&frontmatter).context(FrontMatterDecodeSnafu { path })?; frontmatter_from_str(&frontmatter).context(FrontMatterDecodeSnafu { path })?;
let mut parser_options = Options::empty(); let parser_options = Options::ENABLE_TABLES
parser_options.insert(Options::ENABLE_TABLES); | Options::ENABLE_FOOTNOTES
parser_options.insert(Options::ENABLE_FOOTNOTES); | Options::ENABLE_STRIKETHROUGH
parser_options.insert(Options::ENABLE_STRIKETHROUGH); | Options::ENABLE_TASKLISTS
parser_options.insert(Options::ENABLE_TASKLISTS); | Options::ENABLE_MATH;
let mut ref_parser = RefParser::new(); let mut ref_parser = RefParser::new();
let mut events = vec![]; let mut events = vec![];

View File

@ -0,0 +1,11 @@
This sentence uses `$` delimiters to show math inline: $\sqrt{3x-1}+(1+x)^2$
This is the same math expression expressed as a block element:
$$\sqrt{3x-1}+(1+x)^2$$
<!-- https://github.com/zoni/obsidian-export/issues/14 -->
With square brackets (inline): $[0, 2\pi]$
With square brackets (block):
$$[0, 2\pi]$$

View File

@ -0,0 +1,10 @@
This sentence uses `$` delimiters to show math inline: $\sqrt{3x-1}+(1+x)^2$
This is the same math expression expressed as a block element:
$$\sqrt{3x-1}+(1+x)^2$$
<!-- https://github.com/zoni/obsidian-export/issues/14 -->
With square brackets (inline): $[0, 2\pi]$
With square brackets (block):
$$[0, 2\pi]$$