mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
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.
This commit is contained in:
parent
82ad6afd36
commit
7e6b007dd5
|
@ -43,10 +43,12 @@ export async function activate(ctx: RendererContext<void>) {
|
||||||
document.head.appendChild(styleTemplate);
|
document.head.appendChild(styleTemplate);
|
||||||
|
|
||||||
const katex = require('@iktakahiro/markdown-it-katex');
|
const katex = require('@iktakahiro/markdown-it-katex');
|
||||||
|
const macros = {};
|
||||||
markdownItRenderer.extendMarkdownIt((md: markdownIt.MarkdownIt) => {
|
markdownItRenderer.extendMarkdownIt((md: markdownIt.MarkdownIt) => {
|
||||||
return md.use(katex, {
|
return md.use(katex, {
|
||||||
globalGroup: true,
|
globalGroup: true,
|
||||||
enableBareBlocks: true,
|
enableBareBlocks: true,
|
||||||
|
macros
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,9 @@ export function activate(context: vscode.ExtensionContext) {
|
||||||
extendMarkdownIt(md: any) {
|
extendMarkdownIt(md: any) {
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
const katex = require('@iktakahiro/markdown-it-katex');
|
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;
|
return md;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue