eipw icon indicating copy to clipboard operation
eipw copied to clipboard

`markdown-link-first` incorrectly matches inside image alt text

Open SamWilsn opened this issue 1 year ago • 3 comments

For example:

error[markdown-link-first]: the first match of the given pattern must be a link
  --> ERCS/erc-7615.md
   |
65 | ![ERC-7615 Workflow](../assets/erc-7615/ERC7615.svg)
   |
   = info: the pattern in question: `(?i)(?:eip|erc)-[0-9]+`
   = help: see https://ethereum.github.io/eipw/markdown-link-first/

Found in https://github.com/ethereum/ERCs/actions/runs/9476286533/job/26108931430?pr=235

SamWilsn avatar Jun 13 '24 16:06 SamWilsn

@SamWilsn can I have this one?

rutefig avatar Jun 14 '24 12:06 rutefig

So i think the main issue here is that that function is checking if the first reference for some proposal it is a link for that proposal which makes sense which the reference is not the proposal itself, which in this case was. To solve this I think there can be two approaches, or just ignore this check everytime the proposal reference is inside of the image alt, or skip the check if the proposal being referenced has the same id as the document. @SamWilsn

rutefig avatar Jun 20 '24 16:06 rutefig

You cannot place links in an image alt text, at least as far as I know, so ignoring this lint for all image alt texts makes the most sense to me. I think you can do that somewhere around:

https://github.com/ethereum/eipw/blob/db50295b89f65329e9c07dec8e9f518b8c064e3c/eipw-lint/src/lints/markdown/link_first.rs#L143-L145

SamWilsn avatar Jun 20 '24 16:06 SamWilsn