mathjax / MathJax-node

MathJax for Node
Apache License 2.0
614 stars 96 forks source link

With useGlobalCache, first typeset still has defs #398

Closed pkra closed 6 years ago

pkra commented 6 years ago

This is a regression (tested in 2.0.1).

Minimal sample:

const mj = require('mathjax-node').typeset;
const state= {};
    mj({
        math: '<math><mi>x</mi></math>',
        format: 'MathML',
        svg: true,
        useGlobalCache: true,
        state: state
    }, function(result){
        console.log(result.svg) // still has defs
    });
    mj({
        math: '<math><mi>a</mi></math>',
        format: 'MathML',
        svg: true,
        useGlobalCache: true,
        state: state
    }, function(result){
        console.log(result.svg) // does not
    });
pkra commented 6 years ago

This appears fixed on the develop branch.

pkra commented 6 years ago

Probably related to https://github.com/mathjax/MathJax-node/issues/392.

Perhaps an additional test would be good since this is a nasty little bug that easily causes invalid markup downt the line (duplicate IDs due to repeated paths).

dpvc commented 6 years ago

Probably related to #392.

In fact exactly the same issue. The SVG configuration parameter were being wiped out for the first SVG element produced because they were being set beforeSVG was loaded, and then when SVG was loaded, they were being overwritten by the SVG defaults. The fix for 392 is the same as for this, which is why it works in develop.

The test file for the presence of useFontCache should be sufficient of this as well, since both are set or overridden in the same way.

pkra commented 6 years ago

I think this can be closed now that 2.1.0 has been released.