mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD045/no-alt-text to allow violations when an HTML IMG has aria-hidden set to true (fixes #1576).
This commit is contained in:
parent
faf96d513b
commit
b611eba684
7 changed files with 70 additions and 4 deletions
|
@ -5,6 +5,7 @@ import { getHtmlTagInfo, getDescendantsByType } from "../helpers/micromark-helpe
|
|||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const altRe = getHtmlAttributeRe("alt");
|
||||
const ariaHiddenRe = getHtmlAttributeRe("aria-hidden");
|
||||
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
|
@ -40,7 +41,8 @@ export default {
|
|||
htmlTagInfo &&
|
||||
!htmlTagInfo.close &&
|
||||
(htmlTagInfo.name.toLowerCase() === "img") &&
|
||||
!altRe.test(text)
|
||||
!altRe.test(text) &&
|
||||
(ariaHiddenRe.exec(text)?.[1].toLowerCase() !== "true")
|
||||
) {
|
||||
const range = [
|
||||
startColumn,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue