Update MD040/fenced-code-language to add language_only parameter to reject extra data in info string.

This commit is contained in:
Sébastien Règne 2022-11-11 07:07:04 +01:00 committed by GitHub
parent 718de432f3
commit 72439f42c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 176 additions and 1 deletions

View file

@ -4176,6 +4176,7 @@ module.exports = {
"function": function MD040(params, onError) {
let allowed = params.config.allowed_languages;
allowed = Array.isArray(allowed) ? allowed : [];
const languageOnly = !!params.config.language_only;
filterTokens(params, "fence", function forToken(token) {
const lang = token.info.trim().split(/\s+/u).shift();
if (lang === "") {
@ -4184,6 +4185,9 @@ module.exports = {
else if ((allowed.length > 0) && !allowed.includes(lang)) {
addError(onError, token.lineNumber, `"${lang}" is not allowed`);
}
if (languageOnly && (token.info !== lang)) {
addError(onError, token.lineNumber, `Info string contains more than language: "${token.info}"`);
}
});
}
};