2022-11-28 07:12:09PM

This commit is contained in:
Alexander Wang 2022-11-28 19:12:09 -08:00
parent 3d6c19697e
commit 160fa4451c
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
4 changed files with 43 additions and 5 deletions

View file

@ -44,7 +44,7 @@ func Render(s string) (_ string, err error) {
return "", err
}
val, err := v8ctx.RunScript(fmt.Sprintf(`adaptor.innerHTML(html.convert("%s", {
val, err := v8ctx.RunScript(fmt.Sprintf(`adaptor.innerHTML(html.convert(`+"`"+"%s`"+`, {
em: %d,
ex: %d,
}))`, s, pxPerEx*2, pxPerEx), "value.js")

View file

@ -7,8 +7,11 @@ import (
func TestRender(t *testing.T) {
txts := []string{
`a + b = c`,
`\\frac{1}{2}`,
// `a + b = c`,
// `\\frac{1}{2}`,
`a + b
= c
`,
}
for _, txt := range txts {
svg, err := Render(txt)

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
const adaptor = MathJax._.adaptors.liteAdaptor.liteAdaptor();
MathJax._.handlers.html_ts.RegisterHTMLHandler(adaptor)
const html = MathJax._.mathjax.mathjax.document('', {
InputJax: new MathJax._.input.tex_ts.TeX(),
InputJax: new MathJax._.input.tex_ts.TeX({ packages: ['base', 'mathtools', 'amscd', 'braket', 'cancel', 'cases', 'color', 'gensymb', 'mhchem', 'physics'] }),
OutputJax: new MathJax._.output.svg_ts.SVG(),
});