aboutsummaryrefslogtreecommitdiffstats
path: root/spring-front/src/parse_worker.js
blob: 8bcf0adc00100465a70c92d33daa2e22d7f3a540 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
);