Pass one shared `macros` object into every call to katex renderer (#148006)
* Pass one shared `macros` object into every call to katex renderer. * Reset the `macros` object at each new re-rendering.pull/148576/head
parent
82ad6afd36
commit
7e6b007dd5
|
@ -43,10 +43,12 @@ export async function activate(ctx: RendererContext<void>) {
|
|||
document.head.appendChild(styleTemplate);
|
||||
|
||||
const katex = require('@iktakahiro/markdown-it-katex');
|
||||
const macros = {};
|
||||
markdownItRenderer.extendMarkdownIt((md: markdownIt.MarkdownIt) => {
|
||||
return md.use(katex, {
|
||||
globalGroup: true,
|
||||
enableBareBlocks: true,
|
||||
macros
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,7 +24,9 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
extendMarkdownIt(md: any) {
|
||||
if (isEnabled()) {
|
||||
const katex = require('@iktakahiro/markdown-it-katex');
|
||||
return md.use(katex, { globalGroup: true });
|
||||
const options = { globalGroup: true, macros: {} };
|
||||
md.core.ruler.push('reset-katex-macros', () => { options.macros = {}; });
|
||||
return md.use(katex, options);
|
||||
}
|
||||
return md;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue