Giter Site home page Giter Site logo

MD051 support icon about markdownlint HOT 11 CLOSED

unional avatar unional commented on May 24, 2024
MD051 support icon

from markdownlint.

Comments (11)

DavidAnson avatar DavidAnson commented on May 24, 2024

This rule expects the GitHub representation which is described at the bottom of the documentation and does not include emoji: https://github.com/DavidAnson/markdownlint/blob/main/doc/md051.md

If that representation is used, no warning is produced: https://dlaa.me/markdownlint/#%25m%23%20%F0%9F%94%80%20Distributive%0A%0A%5B%F0%9F%94%80%20distributive%5D(%23-distributive)%0A

The rule is operating as intended.

from markdownlint.

unional avatar unional commented on May 24, 2024

Maybe this is an issue on vscode. The #-distributive without the emoji does not work.

from markdownlint.

DavidAnson avatar DavidAnson commented on May 24, 2024

From what I can tell, GitHub web does not recognize the link in your example - whereas it does for the link that markdownlint accepts in my demo. In the interest of supporting a single canonical way of defining heading links which are not part of the CommonMark specification, GitHub seems to be the next-best authority on Markdown (see: GitHub Flavored Markdown). As such, I feel the current behavior of markdownlint is reasonable and I encourage you to open an issue in the VS Code repo for them to allow or convert to GitHub's approach.

from markdownlint.

giacomorebecchi avatar giacomorebecchi commented on May 24, 2024

Hi, I stumbled upon this issue as well. I realised that mkdocs removes the leading -, hence in your case the correct link would be #distributive. Do you think there is the space to add a possibility to configure the removal of leading dashes? Thanks!

from markdownlint.

DavidAnson avatar DavidAnson commented on May 24, 2024

@giacomorebecchi, can you link to the documentation, specification, or implementation of that mkdocs behavior?

from markdownlint.

giacomorebecchi avatar giacomorebecchi commented on May 24, 2024

@giacomorebecchi, can you link to the documentation, specification, or implementation of that mkdocs behavior?

I couldn't find an explicit reference in the documentation, but, after a bit of deep-diving, I found out that:

  1. Anchoring links in mkdocs are calculated by the toc extension
  2. toc calls the slugify function to transform a Heading into the correct link (see here the source code)
slugify(" My test 🐛", "-") == "my-test"
slugify("🐛 My test 🐛", "-") == "my-test"

The reason is that it calls strip before replacing whitespaces with -

from markdownlint.

unional avatar unional commented on May 24, 2024

FYI you can see that the issue on vscode is closed: microsoft/vscode-markdown-languageservice#171

Next version of vscode will have the fix.

vscode will be using https://github.com/Flet/github-slugger

from markdownlint.

DavidAnson avatar DavidAnson commented on May 24, 2024

Thanks! It sounds like VS Code is also standardizing on GitHub behavior. That doesn't mean markdownlint can't also allow other forms, but it makes it a bit less interesting in my mind.

from markdownlint.

giacomorebecchi avatar giacomorebecchi commented on May 24, 2024

@DavidAnson I understand that it looks minor to you, but do you see the opportunity to accept a contribution to make this behaviour parametrisable? It would turn out to be very useful for me! If yes, I could try to work on it (although I've never written anything in JS, but that would be a nice chance to learn). Thanks in advance!

from markdownlint.

DavidAnson avatar DavidAnson commented on May 24, 2024

@giacomorebecchi I'm not intimidated by the amount of work here. I am questioning whether it is a good change to add. So far, when dealing with syntax and behavior that is not part of the CommonMark specification, I have used the GitHub-Flavored Markdown specification and that has worked well. This behavior is not described there, but by matching GitHub, I feel this behavior is consistent with that spirit.

The kind of changes here do not seem to lend themselves to expressing abstractly with text or regular expression, so the customization mechanism may need to be implementing multiple behaviors in the rule and allowing people to choose among them. (Allowing both implementations together creates situations where mistakes are not detected.) That is additional complexity for me to deal with and it opens the door for people with other scenarios to want to add them as well. My impression (and I do not have data for this, so would welcome it!) is that GitHub and VS Code represent the vast majority of the use of heading links in practice, so the benefits of doing so are limited.

from markdownlint.

giacomorebecchi avatar giacomorebecchi commented on May 24, 2024

@DavidAnson I understand your point, thanks for the detailed explanation! I have no data regarding usage of GitHub and VSCode w.r.t. Mkdocs. I think I will proceed by making an alternative extension to toc that follows GitHub-Flavored Markdown specification. Thanks again for your work and support!

from markdownlint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.