Skip to content

Commit fbc4b86

Browse files
authored
Merge pull request microsoft#235880 from RedCMD/extensionCodeblockLangFix
Fix extension preview codeblock language getter
2 parents 7722c2b + 4422cea commit fbc4b86

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export async function renderMarkdownDocument(
234234
namespace MarkedHighlight {
235235
// Copied from https://github.com/markedjs/marked-highlight/blob/main/src/index.js
236236

237-
export function markedHighlight(options: marked.MarkedOptions & { highlight: (code: string, lang: string, info: string) => string | Promise<string> }): marked.MarkedExtension {
237+
export function markedHighlight(options: marked.MarkedOptions & { highlight: (code: string, lang: string) => string | Promise<string> }): marked.MarkedExtension {
238238
if (typeof options === 'function') {
239239
options = {
240240
highlight: options,
@@ -252,13 +252,11 @@ namespace MarkedHighlight {
252252
return;
253253
}
254254

255-
const lang = getLang(token.lang);
256-
257255
if (options.async) {
258-
return Promise.resolve(options.highlight(token.text, lang, token.lang || '')).then(updateToken(token));
256+
return Promise.resolve(options.highlight(token.text, token.lang)).then(updateToken(token));
259257
}
260258

261-
const code = options.highlight(token.text, lang, token.lang || '');
259+
const code = options.highlight(token.text, token.lang);
262260
if (code instanceof Promise) {
263261
throw new Error('markedHighlight is not set to async but the highlight function is async. Set the async option to true on markedHighlight to await the async highlight function.');
264262
}
@@ -276,10 +274,6 @@ namespace MarkedHighlight {
276274
};
277275
}
278276

279-
function getLang(lang: string) {
280-
return (lang || '').match(/\S*/)![0];
281-
}
282-
283277
function updateToken(token: any) {
284278
return (code: string) => {
285279
if (typeof code === 'string' && code !== token.text) {

0 commit comments

Comments
 (0)