From f87369e1af097d3cef03cdff5395fd8515a06a41 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 5 Oct 2018 13:06:26 -0700 Subject: [PATCH] Treat json5 as json in the markdown preview --- extensions/markdown-language-features/src/markdownEngine.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/markdown-language-features/src/markdownEngine.ts b/extensions/markdown-language-features/src/markdownEngine.ts index 26028af3322..909bc760c2f 100644 --- a/extensions/markdown-language-features/src/markdownEngine.ts +++ b/extensions/markdown-language-features/src/markdownEngine.ts @@ -39,11 +39,14 @@ export class MarkdownEngine { const mdnh = await import('markdown-it-named-headers'); this.md = (await import('markdown-it'))({ html: true, - highlight: (str: string, lang: string) => { + highlight: (str: string, lang?: string) => { // Workaround for highlight not supporting tsx: https://github.com/isagalaev/highlight.js/issues/1155 if (lang && ['tsx', 'typescriptreact'].indexOf(lang.toLocaleLowerCase()) >= 0) { lang = 'jsx'; } + if (lang && lang.toLocaleLowerCase() === 'json5') { + lang = 'json'; + } if (lang && hljs.getLanguage(lang)) { try { return `
${hljs.highlight(lang, str, true).value}
`;