Skip to content

Commit afbec20

Browse files
authored
Fix markdown-it-katex error (microsoft#202393)
1 parent bb866cd commit afbec20

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

extensions/markdown-language-features/notebook/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,11 @@ export const activate: ActivationFunction<void> = (ctx) => {
342342
}
343343
},
344344
extendMarkdownIt: (f: (md: typeof markdownIt) => void) => {
345-
f(markdownIt);
345+
try {
346+
f(markdownIt);
347+
} catch (err) {
348+
console.error('Error extending markdown-it', err);
349+
}
346350
}
347351
};
348352
};

extensions/markdown-math/notebook/katex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function activate(ctx: RendererContext<void>) {
4545
styleTemplate.content.appendChild(link);
4646
document.head.appendChild(styleTemplate);
4747

48-
const katex = require('@vscode/markdown-it-katex');
48+
const katex = require('@vscode/markdown-it-katex').default;
4949
const macros = {};
5050
markdownItRenderer.extendMarkdownIt((md: markdownIt.MarkdownIt) => {
5151
return md.use(katex, {

extensions/markdown-math/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"build-notebook": "node ./esbuild"
9999
},
100100
"dependencies": {
101-
"@vscode/markdown-it-katex": "^1.0.1"
101+
"@vscode/markdown-it-katex": "^1.0.2"
102102
},
103103
"devDependencies": {
104104
"@types/markdown-it": "^0.0.0",

extensions/markdown-math/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function activate(context: vscode.ExtensionContext) {
2828
return {
2929
extendMarkdownIt(md: any) {
3030
if (isEnabled()) {
31-
const katex = require('@vscode/markdown-it-katex');
31+
const katex = require('@vscode/markdown-it-katex').default;
3232
const settingsMacros = getMacros();
3333
const options = { globalGroup: true, macros: { ...settingsMacros } };
3434
md.core.ruler.push('reset-katex-macros', () => {

extensions/markdown-math/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
resolved "https://registry.yarnpkg.com/@types/vscode-notebook-renderer/-/vscode-notebook-renderer-1.72.0.tgz#8943dc3cef0ced2dfb1e04c0a933bd289e7d5199"
1313
integrity sha512-5iTjb39DpLn03ULUwrDR3L2Dy59RV4blSUHy0oLdQuIY11PhgWO4mXIcoFS0VxY1GZQ4IcjSf3ooT2Jrrcahnw==
1414

15-
"@vscode/markdown-it-katex@^1.0.1":
16-
version "1.0.1"
17-
resolved "https://registry.yarnpkg.com/@vscode/markdown-it-katex/-/markdown-it-katex-1.0.1.tgz#79c6e7312074e1f897cc22c42ce078d1e72003b0"
18-
integrity sha512-O/HiT5Uc6rN6rSx8tDdgwO1tLSn/lrNeikTzYw1EBG6B2IGLKw4I4e/GBh9DRNSdE9PajCA0tsVBz86qyA7B3A==
15+
"@vscode/markdown-it-katex@^1.0.2":
16+
version "1.0.2"
17+
resolved "https://registry.yarnpkg.com/@vscode/markdown-it-katex/-/markdown-it-katex-1.0.2.tgz#27ba579fa3896b2944b71209dd30d0f983983f11"
18+
integrity sha512-QY/OnOHPTqc8tQoCoAjVblILX4yE6xGZHKODtiTKqA328OXra+lSpeJO5Ouo9AAvrs9AwcCLz6xvW3zwcsPBQg==
1919
dependencies:
2020
katex "^0.16.4"
2121

0 commit comments

Comments
 (0)