DavidAnson / markdownlint

A Node.js style checker and lint tool for Markdown/CommonMark files.
MIT License
4.71k stars 715 forks source link

Link fragments shows warning MD051 when target is preceeded by emoji. #1277

Closed AxelBrinck closed 2 months ago

AxelBrinck commented 2 months ago

Hi there! 👋🏻

Thanks for the work on this great repository.

Link fragments to sections works fine, until the section has an emoji :crying_cat_face:

The following link:

- [Username Created](#-username-created).

Redirects to the following section:

### :arrow_left: Username Created

But at the same time shows warning: MD051.

The warning disappears if the emoji and the "-" symbol prefixing the link is removed.

I read that prefixing headers with an "-" in link fragments should allow to have an emoji.

Can this be reviewed?

Thanks!

DavidAnson commented 2 months ago

Per the documentation, MD051 uses the GitHub heading algorithm as the canonical form for headings:

https://github.com/DavidAnson/markdownlint/blob/main/doc/md051.md

As you can confirm via GitHub, the GitHub representation for the link you show is this:

#arrow_left-username-created

Using that in Markdown produces no violations from MD051, so I claim the rule is behaving correctly:

https://dlaa.me/markdownlint/#%25m%23%20Issue%201277%0A%0A%23%23%20%3Aarrow_left%3A%20Username%20Created%0A%0A-%20%5BUsername%20Created%5D(%23arrow_left-username-created).%0A

AxelBrinck commented 2 months ago

Ah, yes, this works! Thanks a lot for helping! 😸