All files / markdown / plugins / math.ts

100.00% Branches 0/0
100.00% Lines 10/10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
 
x2
x2
 
 
 
 
 
 
 
 
 
 
 
 
x2
x2
x3
x2
x2
x3
x3
x2





















// Imports
import type { Plugin } from "../renderer.ts"
import remarkMath from "remark-math"
import rehypeMathjax from "rehype-mathjax"

/**
 * Add support for math.
 *
 * {@link https://www.mathjax.org | See MathJax documentation for more information}.
 *
 * ```md
 * $$
 * \frac{1}{2}
 * $$
 * ```
 */
export default {
  remark(processor) {
    return processor.use(remarkMath)
  },
  rehype(processor) {
    return processor.use(rehypeMathjax)
  },
} as Plugin