Braces in latex get escaped

I’m using a simple template with KaTeX and the following fails:
$$\mathcal I := { X\subset E : \text{the vectors in $X$ are linearly independent} }.$$

I suspect this is due to Hugo automatically replacing { → {, and I check this by testing $a_{b}$.

How can I go around this, so that my LaTeX code also works on other markdown parsers that do not do this replacement?

Going to bump this. To summarize, \{ is being replaced with {, probably due to HTML escaping.

I recently got a contribution to my Zen theme that implements KaTeX. Tested your example and it seems to work just fine. At least it renders the same way as it does on

If you post a link to your repo we can check what the difference are.