mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01:00
Add getHtmlAttributeRe helper for creating a RegExp to match an HTML attribute name/value.
This commit is contained in:
parent
531e58ed9a
commit
06466905a5
4 changed files with 36 additions and 15 deletions
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addError, nextLinesRe } = require("../helpers");
|
||||
const { addError, getHtmlAttributeRe, nextLinesRe } = require("../helpers");
|
||||
const { filterByTypes, getHtmlTagInfo } = require("../helpers/micromark.cjs");
|
||||
|
||||
// Regular expression for identifying alt attribute
|
||||
const altRe = /\salt=/i;
|
||||
const altRe = getHtmlAttributeRe("alt");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD045", "no-alt-text" ],
|
||||
|
|
@ -40,6 +39,7 @@ module.exports = {
|
|||
const htmlTagInfo = getHtmlTagInfo(htmlText);
|
||||
if (
|
||||
htmlTagInfo &&
|
||||
!htmlTagInfo.close &&
|
||||
(htmlTagInfo.name.toLowerCase() === "img") &&
|
||||
!altRe.test(text)
|
||||
) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue