mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-18 06:50:12 +01:00
Update MD040/fenced-code-language to add language_only parameter to reject extra data in info string.
This commit is contained in:
parent
718de432f3
commit
72439f42c6
13 changed files with 176 additions and 1 deletions
10
lib/md040.js
10
lib/md040.js
|
|
@ -11,6 +11,8 @@ 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 === "") {
|
||||
|
|
@ -22,6 +24,14 @@ module.exports = {
|
|||
`"${lang}" is not allowed`
|
||||
);
|
||||
}
|
||||
|
||||
if (languageOnly && (token.info !== lang)) {
|
||||
addError(
|
||||
onError,
|
||||
token.lineNumber,
|
||||
`Info string contains more than language: "${token.info}"`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue