vericast / nbconflux

nbconflux converts Jupyter Notebooks to Atlassian Confluence pages
BSD 3-Clause "New" or "Revised" License
117 stars 33 forks source link

Problem with certain characters when using LaTeX in code cells #14

Open susanxia1006 opened 6 years ago

susanxia1006 commented 6 years ago

Some characters do not appear to be escaped correctly when using the Math class from IPython.display.

Example: the output cell of

from IPython.display import Math
Math(r"""\begin{eqnarray}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = & \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = & 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = & \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = & 0 
\end{eqnarray}""")

gives error

400 Client Error: Bad Request for url...

But it works fine after taking out all the & characters.

parente commented 5 years ago

Assuming Math() emits a mimetype bundle, we need to escape special characters just like we do with MathJax embedded in Markdown.