Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MD040: Add disallowed_languages #1012

Open
dsanders11 opened this issue Oct 17, 2023 · 2 comments
Open

MD040: Add disallowed_languages #1012

dsanders11 opened this issue Oct 17, 2023 · 2 comments

Comments

@dsanders11
Copy link

Currently MD040 lets you set allowed_languages, but that's not a good fit if you only want to disallow a couple of specific languages. Adding a disallowed_languages parameter could handle that case. Should probably only allow one of those parameters or the other, but not both, since they're contradictory.

Bonus points if disallowed_languages could be a string[] or a mapping of languages to their preferred alternative, e.g.:

"fenced-code-language": {
  "disallowed_languages": {
    "js": "javascript"
  }
}

would produce an error telling the user to use javascript instead of js as the language identifier.

@DavidAnson
Copy link
Owner

I like the idea of providing alternate suggestions, though that could be incorporated into the current implementation. I'm curious why you think it's easier to exclude languages? In the proposed model, someone could accidentally use the identifier "javasript" and it would be okay unless you specifically blocked that in advance. Because the list of valid languages is so small, an allow list (like the current implementation) seems safer?

@dsanders11
Copy link
Author

Fair points.

In projects with a large amount of docs covering a wide range of topics (doing a quick count, the Electron docs would need to add 16+ languages to the allow list), I'd personally prefer using a disallow list as it is easier for new contributors who might be introducing a code block with a new language identifier. Usually linting failures just require you to modify your own added content to fix them, but with the allow list a contributor would need to find and understand the markdownlint configuration to update the allow list, which requires a bit more technical knowledge than a contributor adding to Markdown docs may have.

So for me I'd prefer to not add an additional potential barrier to entry for contributors, at the cost of potentially letting errors slip in (like your very valid "javasript" example). I can deal with the latter out-of-band without blocking contributors, and use the disallow list to still cover it 90% of the time (outright typos aren't very common compared to using javascript vs js, etc).

I think there's value in having both options supported, but I can understand if you'd prefer to keep it simpler for maintenance reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants