From e83655d95a2c302d464e8fa38788df96a6982535 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 24 Aug 2020 19:45:25 -0400 Subject: [PATCH] Update *-page to not include styles if no math is found (speech version) --- speech/mml2svg-page | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/speech/mml2svg-page b/speech/mml2svg-page index 453aa32..0a71c8e 100755 --- a/speech/mml2svg-page +++ b/speech/mml2svg-page @@ -97,8 +97,11 @@ require('mathjax-full/' + (argv.dist ? 'es5' : 'components/src/mml-svg') + '/mml MathJax.startup.promise.then(() => { const adaptor = MathJax.startup.adaptor; const html = MathJax.startup.document; - MathJax.startup.promise.then(() => { - console.log(adaptor.doctype(html.document)); - console.log(adaptor.outerHTML(adaptor.root(html.document))); - }); + if (html.math.toArray().length === 0) { + adaptor.remove(html.outputJax.svgStyles); + const cache = adaptor.elementById(adaptor.body(html.document), 'MJX-SVG-global-cache'); + if (cache) adaptor.remove(cache); + } + console.log(adaptor.doctype(html.document)); + console.log(adaptor.outerHTML(adaptor.root(html.document))); }).catch(err => console.log(err));