Skip to content

Jupyter/IPython notebook math with comparisons < or > in formula prevents render

Summary

Inline math inside a jupyter/ipython notebook with a less than operator < or a greater than operator > inside the formula causes the formula to not be rendered, but written in plain text

Steps to reproduce

  • Create an ipython notebook
  • Add a cell with markdown
  • Add an inline math formula using single $ with < or > as part of the formula
  • Upload the notebook to gitlab
  • try to view the notebook in gitlab

Example markdown

###  Cell 1 inline Math examples with `\lt` and `\gt`

Inline Math with single `$` ticks $a + b \lt c$ inside a block

Inline Math with single `$` ticks $a + b \gt c$ inside a block

- Inline Math with single `$` ticks $a + b \lt c$ inside an enumeration using `-`
- Inline Math with single `$` ticks $a + b \gt c$ inside an enumeration using `-`

Padding

* Inline Math with single `$` ticks $a + b \lt c$ inside an enumeration using `*`
* Inline Math with single `$` ticks $a + b \gt c$ inside an enumeration using `*`

Padding

1. Inline Math with single `$` ticks $a + b \lt c$ inside an enumeration using `1.`
1. Inline Math with single `$` ticks $a + b \gt c$ inside an enumeration using `1.`
###  Cell 2 inline Math examples with `<` and `>`

Inline Math with single `$` ticks $a + b < c$ inside a block

Inline Math with single `$` ticks $a + b > c$ inside a block

- Inline Math with single `$` ticks $a + b < c$ inside an enumeration using `-`
- Inline Math with single `$` ticks $a + b > c$ inside an enumeration using `-`

Padding

* Inline Math with single `$` ticks $a + b < c$ inside an enumeration using `*`
* Inline Math with single `$` ticks $a + b > c$ inside an enumeration using `*`

Padding

1. Inline Math with single `$` ticks $a + b < c$ inside an enumeration using `1.`
1. Inline Math with single `$` ticks $a + b > c$ inside an enumeration using `1.`

Example Project

https://gitlab.com/NeroBurner/ipython_katex_test/-/blob/master/ipython_inline_math_comparison_examples.ipynb

What is the current bug behavior?

The formula is not rendered, but the fallback as written text is used.

What is the expected correct behavior?

The formula should be rendered

Relevant logs and/or screenshots

The cell (number 1 and 2) rendered in jupyter notebook (how it should be):

render in jupyter notebook

The cells (number 1 and 2) rendered on gitlab.com (wrong behavior):

render in gitlab.com

Output of checks

This bug happens on GitLab.com

Possible fixes

katex rendering is done in markdown.vue

Edited by NeroBurner