A simple markdown-it plugin for rendering KaTeX formulas generated by the GPT series LLM.
Default parsing of (\[, \]) and (\(, \)) two sets of tokens.
npm install markdown-it-katex-gpt
import MarkdownIt from 'markdown-it'
import markdownItKatexGpt from 'markdown-it-katex-gpt'
const md = new MarkdownIt()
md.use(markdownItKatexGpt)
let result = md.render(`
\\[ F = G \\frac{{m_1 \\times m_2}}{{r^2}} \\]
\\( \\boxed{\\pi=\\frac c d} \\) | \\( a\\raisebox{0.25em}{$b$}c \\) | \\( \\overbrace{a+b+c}^{\\text{note}} \\)
\\( \\Braket{ ϕ | \\frac{∂^2}{∂ t^2} | ψ } \\)
\\[
x = \\begin{cases}
a &\\text{if } b \\\\
c &\\text{if } d
\\end{cases}
\\]
`)
console.log(result)
md.use(markdownItKatexGpt, {
delimiters: [
{ left: '\\[', right: '\\]', display: true },
{ left: '\\(', right: '\\)', display: false },
{ left: '$$', right: '$$', display: false },
]
})