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:
parent
6d0e693ed7
commit
e2ef435f04
1
changelog.d/14.breaking.md
Symbolic link
1
changelog.d/14.breaking.md
Symbolic link
@ -0,0 +1 @@
|
||||
252.breaking.md
|
4
changelog.d/14.fix.md
Normal file
4
changelog.d/14.fix.md
Normal 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
1
changelog.d/252.fix.md
Symbolic link
@ -0,0 +1 @@
|
||||
14.fix.md
|
1
changelog.d/259.breaking.md
Symbolic link
1
changelog.d/259.breaking.md
Symbolic link
@ -0,0 +1 @@
|
||||
252.breaking.md
|
10
src/lib.rs
10
src/lib.rs
@ -483,11 +483,11 @@ impl<'a> Exporter<'a> {
|
||||
let frontmatter =
|
||||
frontmatter_from_str(&frontmatter).context(FrontMatterDecodeSnafu { path })?;
|
||||
|
||||
let mut parser_options = Options::empty();
|
||||
parser_options.insert(Options::ENABLE_TABLES);
|
||||
parser_options.insert(Options::ENABLE_FOOTNOTES);
|
||||
parser_options.insert(Options::ENABLE_STRIKETHROUGH);
|
||||
parser_options.insert(Options::ENABLE_TASKLISTS);
|
||||
let parser_options = Options::ENABLE_TABLES
|
||||
| Options::ENABLE_FOOTNOTES
|
||||
| Options::ENABLE_STRIKETHROUGH
|
||||
| Options::ENABLE_TASKLISTS
|
||||
| Options::ENABLE_MATH;
|
||||
|
||||
let mut ref_parser = RefParser::new();
|
||||
let mut events = vec![];
|
||||
|
11
tests/testdata/expected/main-samples/math.md
vendored
Normal file
11
tests/testdata/expected/main-samples/math.md
vendored
Normal 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]$$
|
10
tests/testdata/input/main-samples/math.md
vendored
Normal file
10
tests/testdata/input/main-samples/math.md
vendored
Normal 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]$$
|
Loading…
Reference in New Issue
Block a user