You embed KaTeX in your Go program.
Let us first fetch the latest copy of katex.min.js from CDNJS. KaTeX uses the MIT license; make sure to include that in your project.
Next, in your Go program, embed katex.min.js:
And add a Render function that:
- Evaluates the embedded katex.min.js code
- Sets the LaTeX string as a global variable.
katex.renderToStringon the variable with the LaTeX string.
The above code gives you the most straightforward implementation. You may want to rewrite it in a way where you evaluate katex.min.js only once and keep using the same
context for every invocation of
This post is 9th of my #100DaysToOffload challenge. Want to get involved? Find out more at 100daystooffload.com.
comments powered by Disqus