orsharir / github-mathjax

Chrome extension for rendering LaTeX equations in GitHub with MathJax
Other
153 stars 49 forks source link

Problem with <em> block #19

Open remilepriol opened 6 years ago

remilepriol commented 6 years ago

Some of my equations won't be rendered by MathJax for a very simple reason.

I have the following latex formula:

$$n (D(\alpha^+) - D(\alpha)) 
\geq s_i \underbrace{ \big [ \phi(-A_i^Tw) + \phi^*(\alpha_i) + w^T A_i \alpha_i \big ] }_{ \textrm{Fenchel gap}} + s_i \bigg ( \frac{\gamma(1-s_i)}{2} - \frac{s_i \|A_i\|^2_{D\rightarrow D'} }{2 \lambda n} \bigg ) \| \beta_i - \alpha_i \|^2_D$$

It first gets rendered by Github Markdown creating the following HTML code

<p>
    $$n (D(\alpha^+) - D(\alpha)) \geq s_i \underbrace{ \big [ \phi(-A_i^Tw) + \phi^*(\alpha_i) + w^T A_i \alpha_i \big ] }
    <em>
        { \textrm{Fenchel gap}} + s_i \bigg ( \frac{\gamma(1-s_i)}{2} - \frac{s_i |A_i|^2
    </em>
    {D\rightarrow D'} }{2 \lambda n} \bigg ) | \beta_i - \alpha_i |^2_D$$
</p>

MathJax is then unable to process it because the original code has been broken in two parts by the <em> block. There are probably many more problems created by this separate processing of the markdown first and the latex code second. Any idea for a workaround?