mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Refine implementation of MD045/no-alt-text in previous commit.
This commit is contained in:
parent
4fa837a031
commit
f91f0880c3
7 changed files with 61 additions and 44 deletions
|
@ -1222,18 +1222,14 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
"name": "MD045",
|
||||
"desc": "Images should have ALT Text attribute",
|
||||
"desc": "Images should have alternate text (alt text)",
|
||||
"tags": [ "accessibility", "images" ],
|
||||
"aliases": [ "no-alt-text" ],
|
||||
"regexp": null,
|
||||
"func": function MD045(params, errors) {
|
||||
forEachInlineChild(params, "image", function forToken(token) {
|
||||
if (token.content === "") {
|
||||
token.attrs.forEach(function forAttr(attr) {
|
||||
if (attr[0] === "alt" && attr[1] === "") {
|
||||
errors.add(token.lineNumber);
|
||||
}
|
||||
});
|
||||
errors.add(token.lineNumber);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue