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

Errorneous TeX rendering where multiple _ or ^ exist in math expressions #1389

Closed
Gennadiyev opened this issue Jul 11, 2021 · 4 comments · Fixed by #1576
Closed

Errorneous TeX rendering where multiple _ or ^ exist in math expressions #1389

Gennadiyev opened this issue Jul 11, 2021 · 4 comments · Fixed by #1576

Comments

@Gennadiyev
Copy link

Gennadiyev commented Jul 11, 2021

General information

  • App version: 2.7.0
  • Android version: 10
  • Device: HUAWEI Matepad Pro 10.8

Description

An attempt was made to render the following formula:

$\delta ^ {(n)} (at) = \dfrac{1}{|a|} \cdot \dfrac{1}{a ^ n} \delta ^ {(n)} (t)$

But it shows bad results:

Screenshot_20210711_145641.jpg

Similarly, the following equation will also fail to render properly:

$\left.\mathrm{d}x_1\right|_{x_1=a}$

But has a workaround by adding spaces before and after each underscore, to prevent markdown-like syntax from being rendered first.

References

#952 and #825 are two similar issues about rendering TeX, where a suggestion is provided to use <div> to wrap around the markdown block. However, it is a bad practice for markdown writers to use HTML tags within their files. Meanwhile, this issue technically only exist in markor. Because markor is not the only markdown editor I'm currently using, I don't feel necessary to implement this workaround.

Guessings

I haven't run into the codes yet, but it's quite apparent that markor is attempting to parse what's wrapped inside the $...$, which corrupts the expression before it's sent to KaTeX.

I fully understand that it may be part of KaTeX's fault, but I'm a MathJax and KaTeX user, regularly calling them in my own projects without such an error.

I'm not native to English, please forgive for ambiguity.

@Gennadiyev
Copy link
Author

Quick note: #1393 will also be resolved if KaTeX does not parse beforehands.

@gsantner
Copy link
Owner

feel free to improve math support at Markor, and/or Flexmark (Markors markdown parser/converter).

Markor is not a Markdown parser/converter.

@PyTran
Copy link

PyTran commented Aug 9, 2021

$w^{12}$ is very big $w=0$ is nothing

$w^{12}$ is very big $w^0=0$ is nothing

These is also a related problem when there are two superscripts in the same paragraph. In the above the top line renders correctly but the second line does not.

@fgtham
Copy link
Contributor

fgtham commented Feb 3, 2022

The easiest way would be to just disable the flexmark Superscript extension:

SuperscriptExtension.create(), // https://github.com/vsch/flexmark-java/wiki/Extensions#superscript

After commenting this line, all the examples given so far rendered correctly.

Unfortunately, this would reopen #1268.

fgtham pushed a commit to fgtham/markor that referenced this issue Feb 3, 2022
Flexmark would parse and corrupt the contents of KaTeX math expressions.
This commit circumvents the problem by fencing the math expressions.

Fixes gsantner#1389 and gsantner#1393.
gsantner added a commit that referenced this issue Feb 19, 2022
…closes #1393, by @fgtham @gsantner (PR #1576)

* Fence KaTeX math expressions
* Implement flexmark KaTeX extension based on / stripped down flexmark-ext-gitlab
* Update markor-markdown-reference template
* In addition to `$...$` and `$$...$$`, math rendering can now be enabled with `\(...\)` for inline and `\[...¸]` for display mode.

Co-authored-by: Florian Tham <fgt@mailbox.org>
Co-authored-by: Gregor Santner <gsantner@mailbox.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants