Open qnmlgbd250 opened 1 year ago
A little late but i just made this in my own project. It's part of a markdown project but fairly contained so it might be useful to you.
Clone this repo https://github.com/markg85/static-hedgedoc and pull out the js/marks-plugins
folder in your own project.
Fix the paths if needed.
Then it's just as simple as:
import markdownIt from 'markdown-it'
import { KaTeX } from 'marks-plugins'
const md = markdownIt().use(KaTeX)
Do look at my demo html code to get these paths and js in order.
What this does is essentially the latest KaTeX version wrapped in this markdown-it-katex
plugin but tweaked to be modern javascript. It's just a quick couple hour hack to get it working. If there's bugs, let me know! But it should be enough to get you started.
@waylonflinn Would you be open to a PR that is modernizing this code (just uses ESM) and embeds katex in it's repository to make it usable in a stand-alone manner?
If you're not planning on maintaining this anymore then i'd be fine in taking over this repo. I don't really plan to maintain it other then to keep it working. To me it's just one of many plugins that i'd like to keep working in my own static markdown parser project :)
markdown-it-katex How to use it in native JS?