penibelst/jekyll-compress-html

Issue with mathjax display

const7 opened this issue · 7 comments

Some mathjax equation doesn't display when I enable the compress, and when I remove the compress everything works fine.
Specifically, any equation with & in it will cause this problem(at least for my experiments), like:

$$ output \begin{cases} 0, &if\ w·x+b \le 0 \\ 1, &if\ w·x+b \gt 0 \\ \end{cases} $$

or

$$\widetilde{d_t} = \begin{cases} d_t & if d_{t+1} \leq \dfrac{B}{2}\\ d_t+1 & if d_{t+1} > \dfrac{B}{2} \end{cases}$$

and when I remove the & symbol in the equation it will display fine(as long as the syntax of the rest part is legal). But this will cause some changes to the original equation.

So I‘m wondering if there is any way to display the formula correctly without removing the compres ? Hope to get some suggestions, thanks.

btw, I have tried several jekyll themes and the result is all the same. I have also compared mathjax equation html code with or without compress, it seems no difference.

I'm not familiar with mathjax, is this a javascript library? My first instinct is to use & instead if it's just for display

yes, it's a javascript library.

I am also not very familiar with mathjax or html/css so I'm not sure what means it's just for display .😢 I just replaced & with & and it doesn't work.

The & in mathjax is little similar to '\t' in c/c++, for example:
$$ output \begin{cases} 0, &if\ w·x+b \le 0 \\ 1, &if\ w·x+b \gt 0 \\ \end{cases} $$:
image
and equation without & :
$$ output \begin{cases} 0, if\ w·x+b \le 0 \\ 1, if\ w·x+b \gt 0 \\ \end{cases} $$
image

Are you using inline JS? Inline JS isn't supported and will most likely break under JCH (See also #100)

According to the discussion here I think it's not an inline JS.
To use mathjax I just add one line in head.html:

<script src="https://cdn.bootcss.com/mathjax/2.7.7/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>

Yeah that should be fine. What about the mathjax itself? Where do you put the $$... stuff?

In a .md file under the _post directory, just like the normal blog text.

It seems because of the newline.
Problem solved by adding the following lines in _config.yml:

compress_html:
  blanklines: true