diff options
Diffstat (limited to '')
-rw-r--r-- | spring-front/src/parse_worker.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spring-front/src/parse_worker.js b/spring-front/src/parse_worker.js new file mode 100644 index 0000000..8bcf0ad --- /dev/null +++ b/spring-front/src/parse_worker.js @@ -0,0 +1,24 @@ +import mit from "markdown-it"; +import mithljs from "markdown-it-highlightjs"; +import mittexmath from "markdown-it-texmath"; +import mitmmdtable from "markdown-it-multimd-table"; +import katex from "katex"; + +const md = new mit({ html: true }) + .enable(["table"]) + .use(mittexmath, { + engine: katex, + delimiters: "gitlab", + katexOptions: { macros: { "\\RR": "\\mathbb{R}" } }, + }) + .use(mitmmdtable) + .use(mithljs, { inline: true, auto: true, code: true, hljs: hljs }); + +self.addEventListener( + "message", + (event) => { + let htm = md.render(event.target.value); + self.postMessage(htm); + }, + false +); |