From 99ad162fb7b11ac80c787131714c9c8bf66fa8c7 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sat, 14 Jan 2023 20:54:35 +0530 Subject: [PATCH] fix(build): don't warn on blank lang in fences --- src/node/markdown/plugins/highlight.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/node/markdown/plugins/highlight.ts b/src/node/markdown/plugins/highlight.ts index 72bb3f22..d07166e1 100644 --- a/src/node/markdown/plugins/highlight.ts +++ b/src/node/markdown/plugins/highlight.ts @@ -86,16 +86,18 @@ export async function highlight( lang = lang.replace(lineNoRE, '').replace(vueRE, '').toLowerCase() || defaultLang - const langLoaded = highlighter.getLoadedLanguages().includes(lang as any) - if (!langLoaded) { - console.warn( - c.yellow( - `The language '${lang}' is not loaded, falling back to '${ - defaultLang || 'txt' - }' for syntax highlighting.` + if (lang) { + const langLoaded = highlighter.getLoadedLanguages().includes(lang as any) + if (!langLoaded) { + console.warn( + c.yellow( + `The language '${lang}' is not loaded, falling back to '${ + defaultLang || 'txt' + }' for syntax highlighting.` + ) ) - ) - lang = defaultLang + lang = defaultLang + } } const lineOptions = attrsToLines(attrs)