Merge pull request #249 from alixander/mathjax-packages

latex: Fix multiline latex. Add plugins
This commit is contained in:
Alexander Wang 2022-11-28 19:18:45 -08:00 committed by GitHub
commit c167bc4103
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 3 deletions

View file

@ -44,7 +44,7 @@ func Render(s string) (_ string, err error) {
return "", err 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, em: %d,
ex: %d, ex: %d,
}))`, s, pxPerEx*2, pxPerEx), "value.js") }))`, s, pxPerEx*2, pxPerEx), "value.js")

View file

@ -9,6 +9,9 @@ func TestRender(t *testing.T) {
txts := []string{ txts := []string{
`a + b = c`, `a + b = c`,
`\\frac{1}{2}`, `\\frac{1}{2}`,
`a + b
= c
`,
} }
for _, txt := range txts { for _, txt := range txts {
svg, err := Render(txt) 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(); const adaptor = MathJax._.adaptors.liteAdaptor.liteAdaptor();
MathJax._.handlers.html_ts.RegisterHTMLHandler(adaptor) MathJax._.handlers.html_ts.RegisterHTMLHandler(adaptor)
const html = MathJax._.mathjax.mathjax.document('', { 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(), OutputJax: new MathJax._.output.svg_ts.SVG(),
}); });