markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

MD045: no-alt-text triggered even though html alt-text is specified

Open skwde opened this issue 1 year ago • 2 comments

It seems that this should no longer appear, because support was supposedly added through this issue https://github.com/DavidAnson/markdownlint/issues/992 and related merge request https://github.com/DavidAnson/markdownlint/pull/993.

Though I still get this issue.

With following test.md


![](./image.png){fig-alt="Some image"}

I get

test.md:2:1 MD045/no-alt-text Images should have alternate text (alt text) https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md045.md

after running

markdownlint-cli2 test.md

skwde avatar May 07 '24 04:05 skwde

MD045 supports CommonMark syntax for image alternate text (technically the "image description") and the PR referenced above allowed the rule to also recognize alternate text in an HTML IMG tag via the ALT attribute. There are examples of both in the documentation: https://github.com/DavidAnson/markdownlint/blob/main/doc/md045.md

What's shown above in this issue as "fig-alt" is neither of those and therefore not recognized. It looks like this is something Quarto does because it does not use the image description in the standard way: https://quarto.org/docs/authoring/figures.html#alt-text

DavidAnson avatar May 07 '24 16:05 DavidAnson

Quarto’s custom format does not work well with CommonMark syntax as it parses like content and is displayed to the user: https://dlaa.me/markdownlint/#%25m%23%20Issue%201200%0A%0A!%5BElephant%5D(elephant.png)%7Bfig-alt%3D%22A%20drawing%20of%20an%20elephant.%22%7D%0A

DavidAnson avatar May 07 '24 16:05 DavidAnson