Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make options tex_single_backslash_math and tex_double_backslash_math robust against extra spaces #386

Closed
2 tasks
Witiko opened this issue Dec 19, 2023 · 0 comments · Fixed by #399
Closed
2 tasks
Assignees
Labels
bug syntax extension Related to syntax extensions and dialects of markdown
Milestone

Comments

@Witiko
Copy link
Owner

Witiko commented Dec 19, 2023

In #270, we added support for options tex_single_backslash_math and tex_double_backslash_math that add support for writing inline and display math between the separators \(, and \), \[, \] (for option tex_single_backslash_math) and \\(, and \\), \\[, \\] (for option tex_single_backslash_math):

$ docker run -i --rm witiko/markdown markdown-cli texMathSingleBackslash=true <<< '\( 1+2=3 \)'
\markdownRendererDocumentBegin
\markdownRendererInlineMath{1+2=3}\markdownRendererDocumentEnd
$ docker run -i --rm witiko/markdown markdown-cli texMathSingleBackslash=true <<< '\[ 1+2=3 \]'
\markdownRendererDocumentBegin
\markdownRendererDisplayMath{1+2=3}\markdownRendererDocumentEnd
$ docker run -i --rm witiko/markdown markdown-cli texMathDoubleBackslash=true <<< '\\( 1+2=3 \\)'
\markdownRendererDocumentBegin
\markdownRendererInlineMath{1+2=3}\markdownRendererDocumentEnd
$ docker run -i --rm witiko/markdown markdown-cli texMathDoubleBackslash=true <<< '\\[ 1+2=3 \\]'
\markdownRendererDocumentBegin
\markdownRendererDisplayMath{1+2=3}\markdownRendererDocumentEnd

However, introducing spaces around the separators produces unexpected results:

$ docker run -i --rm witiko/markdown markdown-cli texMathSingleBackslash=true <<< '\( 1+2=3 \)'
\markdownRendererDocumentBegin
( 1+2=3 )\markdownRendererDocumentEnd
$ docker run -i --rm witiko/markdown markdown-cli texMathSingleBackslash=true <<< '\[ 1+2=3 \]'
\markdownRendererDocumentBegin
[ 1+2=3 ]\markdownRendererDocumentEnd
$ docker run -i --rm witiko/markdown markdown-cli texMathDoubleBackslash=true <<< '\\( 1+2=3 \\)'
\markdownRendererDocumentBegin
\markdownRendererBackslash{}( 1+2=3 \markdownRendererBackslash{})\markdownRendererDocumentEnd
$ docker run -i --rm witiko/markdown markdown-cli texMathDoubleBackslash=true <<< '\\[ 1+2=3 \\]'
\markdownRendererDocumentBegin
\markdownRendererBackslash{}[ 1+2=3 \markdownRendererBackslash{}]\markdownRendererDocumentEnd

However, Pandoc does not reproduce the above results:

$ pandoc -f markdown+tex_math_single_backslash <<< '\( 1+2=3 \)'
<p><span class="math inline">1 + 2 = 3</span></p>
$ pandoc -f markdown+tex_math_single_backslash <<< '\[ 1+2=3 \]'
<p><br /><span class="math display">1 + 2 = 3</span><br /></p>
$ pandoc -f markdown+tex_math_double_backslash <<< '\\( 1+2=3 \\)'
<p><span class="math inline">1 + 2 = 3</span></p>
$ pandoc -f markdown+tex_math_double_backslash <<< '\\[ 1+2=3 \\]'
<p><br /><span class="math display">1 + 2 = 3</span><br /></p>

Acceptance criteria

  • Update testfiles tests/testfiles/lunamark-markdown/tex-math-*backslash*.test with the above examples.
  • Update the CommonMark parser to be robust against spaces around the separators.
@Witiko Witiko added bug syntax extension Related to syntax extensions and dialects of markdown labels Dec 19, 2023
@Witiko Witiko added this to the 3.4.0 milestone Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug syntax extension Related to syntax extensions and dialects of markdown
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants