Support \gdef in multiple equations in auto-render (#1425)

Within a single call to `renderMathInElement`, default `macros` to a shared
empty object (same as if you specified an object) so that global macros
defined via `\gdef` can be defined and shared.
This commit is contained in:
Erik Demaine
2018-06-14 06:44:43 -04:00
committed by GitHub
parent 4a2903148e
commit ffe90a3ca1
2 changed files with 12 additions and 1 deletions

View File

@@ -101,6 +101,13 @@ const renderMathInElement = function(elem, options) {
}
const optionsCopy = Object.assign({}, defaultAutoRenderOptions, options);
// Enable sharing of global macros defined via `\gdef` between different
// math elements within a single call to `renderMathInElement`.
if (!optionsCopy.macros) {
optionsCopy.macros = {};
}
renderElem(elem, optionsCopy);
};