[GH-ISSUE #670] Add rule to whitelist allowed languages in code fences #498

Closed
opened 2026-03-03 01:27:26 +03:00 by kerem · 1 comment
Owner

Originally created by @Lunkentuss on GitHub (Dec 7, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/670

I often find that languages in code fences contains typos or various alternative spellings, such as "yml" and "yaml" across the repository. This can have critical consequences when tools will only enable syntax highlighting for certain spellings. Therefor it would be nice to have a rule, which is disabled by default to allow backwards compatability, to only allow certain languages.

---
# Default configuration (disabled by default)
MD0XX: false

---
# Override default
MD0XX:
  whitelist: ["yaml", "java", "javascript"]

With the overridden rule, using a fence block such as

```my-non-whitelisted-language
lorem ipsum
```

will fail. I don't know if it makes sense to incorporate this with rule MD040 or not.

Originally created by @Lunkentuss on GitHub (Dec 7, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/670 I often find that languages in code fences contains typos or various alternative spellings, such as "yml" and "yaml" across the repository. This can have critical consequences when tools will only enable syntax highlighting for certain spellings. Therefor it would be nice to have a rule, which is disabled by default to allow backwards compatability, to only allow certain languages. ```yaml --- # Default configuration (disabled by default) MD0XX: false --- # Override default MD0XX: whitelist: ["yaml", "java", "javascript"] ``` With the overridden rule, using a fence block such as ~~~md ```my-non-whitelisted-language lorem ipsum ``` ~~~ will fail. I don't know if it makes sense to incorporate this with rule MD040 or not.
kerem closed this issue 2026-03-03 01:27:26 +03:00
Author
Owner

@Lunkentuss commented on GitHub (Dec 7, 2022):

I'm closing this since I realized a similar issue already exists: https://github.com/DavidAnson/markdownlint/issues/608

<!-- gh-comment-id:1341250365 --> @Lunkentuss commented on GitHub (Dec 7, 2022): I'm closing this since I realized a similar issue already exists: https://github.com/DavidAnson/markdownlint/issues/608
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#498
No description provided.