mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #1012] MD040: Add disallowed_languages #2440
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2440
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dsanders11 on GitHub (Oct 17, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1012
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 adisallowed_languagesparameter 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_languagescould be astring[]or a mapping of languages to their preferred alternative, e.g.:would produce an error telling the user to use
javascriptinstead ofjsas the language identifier.@DavidAnson commented on GitHub (Oct 17, 2023):
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 commented on GitHub (Oct 17, 2023):
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
javascriptvsjs, 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.