12 ms·
We use this with markdown. Basically, we extended our markdown parser to parse anything between two $$ tags as KaTeX. It was really easy to implement. And, KaTe
by supz_k 6y ago
We use this with markdown. Basically, we extended our markdown parser to parse anything between two $$ tags as KaTeX. It was really easy to implement. And, KaTeX is much faster than other alternatives we tested (Yes, that's what title says :) )
- esperent 6y agoHave you encountered the situation where you need to include a $ symbol in your markdown yet? Very tricky and when the issue was raised with katex devs they basically said "not our problem" and closed it.
- dwheeler 6y agoWhy not use $ ?
- esperent 6y agoIt's a while since I encountered this issue but I think the markdown engine was converting that back to $. In the end I had to use <span>$</span> and even that too some jumping through hoops because again markdown was removing html. This was in Hugo, whatever markdown engine they use.
- supz_k 6y agoWe actually use two $$ to start and end. Ex: $$ c = \pm\sqrt{a^2 + b^2} $$ Or, multiline $$ \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } } $$ Some details are available [in this post](https://talk.hyvor.com/blog/introducing-katex-embed/ https://talk.hyvor.com/blog/introducing-katex-embed/) on how it works. And, katex.renderToString has an option to set throwOnError: false.. So, whenever if the TeX code inside $$ is not valid, it just returns the text.
- esperent 6y agoYes, I do the same. I meant when you have to use a currency in dollars in your markdown. Try writing this sentence (sorry, it's early here and I can't think of a better example): I have $3. $$\frac{3}{2}$$