fabiocolacio / Marker

🖊 A gtk3 markdown editor
GNU General Public License v3.0
836 stars 75 forks source link

Marker does not render labeled LaTeX equations with MathJax #247

Closed N0rbert closed 4 years ago

N0rbert commented 6 years ago

Below are examples of the Markdown document with LaTeX equation:

1. Labeled equation with \label{}:

\begin{equation}
  g\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
\label{binom2}
\end{equation}

2. Labeled equation with RMarkdown + bookdown syntax (see this chapter):

\begin{equation} 
  f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
  (\#eq:binom)
\end{equation} 

I have enabled Render Math: MathJax support, but both equations do not render on Marker 2018.07.03. Please allow their rendering.

fabiocolacio commented 5 years ago

Screenshot from 2019-05-04 20-57-36

It is rendering on my machine (compiled from source on Arch)! How did you install Marker and on what OS?

I don't believe scidown renders labels though. Please refer to the info here about scidown.

You can add a caption by making it a figure: Screenshot from 2019-05-04 21-05-44

N0rbert commented 5 years ago

I planned to avoid $$ in the equation declaration. I understood that this functionality is driven by scidown. So current issue may be closed here.

Thank you! The overall functionality of Marker looks great!

N0rbert commented 5 years ago

But I have small question - do you use local copy of MathJax or you download it on the fly? For example, Retext markdown editor download MathJax javascripts on the fly and show labeled equations normally: retext

Is it possible to adjust MathJax settings on Marker side?

N0rbert commented 5 years ago

I compared the HTML output of ReText with Marker.

ReText has the following representation of equations:

<p>
<script type="math/tex; mode=display">\begin{equation}
  g\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
\label{binom2}
\end{equation}</script>
</p>

<p>
<script type="math/tex; mode=display">\begin{equation}
  f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
  (\#eq:binom)
\end{equation}</script>
</p>

and they can be rendered by MathJax.

While Marker converts them to plain text (or simply ignores them):

<p>\begin{equation}
  g\left(k\right) = \binom{n}{k} p<sup>k\left(1-p\right)<sup>{n-k}</sup></sup>
\label{binom2}
\end{equation}</p>

<p>\begin{equation}
  f\left(k\right) = \binom{n}{k} p<sup>k\left(1-p\right)<sup>{n-k}</sup></sup>
  (#eq:binom)
\end{equation}</p>

and they get ignored by MathJax.

Could you please change the Marker behavior with such equation syntax to act as ReText does?

N0rbert commented 4 years ago

Bug exists in Marker 2020.04.04 with MathJax selected to show math.

fabiocolacio commented 4 years ago

To answer your earlier question, Marker has a local installation of mathjax to keep it working offline and to reduce security risks.

The HTML conversion is handeled by scidown, not Marker. This bug should be on the scidown repository.