2022-11-28 07:12:09PM
This commit is contained in:
parent
3d6c19697e
commit
160fa4451c
4 changed files with 43 additions and 5 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
37
d2renderers/d2latex/mathjax.js
vendored
37
d2renderers/d2latex/mathjax.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -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(),
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue