diff --git a/changelog.d/14.breaking.md b/changelog.d/14.breaking.md new file mode 120000 index 0000000..1748068 --- /dev/null +++ b/changelog.d/14.breaking.md @@ -0,0 +1 @@ +252.breaking.md \ No newline at end of file diff --git a/changelog.d/14.fix.md b/changelog.d/14.fix.md new file mode 100644 index 0000000..6779103 --- /dev/null +++ b/changelog.d/14.fix.md @@ -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. diff --git a/changelog.d/252.fix.md b/changelog.d/252.fix.md new file mode 120000 index 0000000..56ead1e --- /dev/null +++ b/changelog.d/252.fix.md @@ -0,0 +1 @@ +14.fix.md \ No newline at end of file diff --git a/changelog.d/259.breaking.md b/changelog.d/259.breaking.md new file mode 120000 index 0000000..1748068 --- /dev/null +++ b/changelog.d/259.breaking.md @@ -0,0 +1 @@ +252.breaking.md \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 7d3e570..bab9cc2 100644 --- a/src/lib.rs +++ b/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![]; diff --git a/tests/testdata/expected/main-samples/math.md b/tests/testdata/expected/main-samples/math.md new file mode 100644 index 0000000..5da3a9c --- /dev/null +++ b/tests/testdata/expected/main-samples/math.md @@ -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$$ + + + +With square brackets (inline): $[0, 2\pi]$ + +With square brackets (block): +$$[0, 2\pi]$$ diff --git a/tests/testdata/input/main-samples/math.md b/tests/testdata/input/main-samples/math.md new file mode 100644 index 0000000..de6923e --- /dev/null +++ b/tests/testdata/input/main-samples/math.md @@ -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$$ + + +With square brackets (inline): $[0, 2\pi]$ + +With square brackets (block): +$$[0, 2\pi]$$