if lang is xml, the language name will result HTML, XML
function test(code, lang) {
let language = hljs.getLanguage(lang)?.name ?? 'plaintext';
return hljs.highlight(code, {language}).value;
}
Then i will get this error:
if i replace HTML, XML to xml, it will work normal:
function test(code, lang) {
let language = hljs.getLanguage(lang)?.name ?? 'plaintext';
if (language == 'HTML,xml') language = 'xml';
return hljs.highlight(code, {language}).value;
}
if
lang
isxml
, the language name will resultHTML, XML
Then i will get this error:
if i replace
HTML, XML
toxml
, it will work normal: