MD040 - Code blocks should have a language specified¶
Aliases: fenced-code-language
What this rule does¶
Ensures code blocks (```) specify what programming language they contain.
Why this matters¶
- Syntax highlighting: Editors and renderers can color-code the syntax correctly
- Clarity: Readers immediately know what language they're looking at
- Tools: Some tools use language hints for processing or validation
Examples¶
✅ Correct¶
```python
def hello():
print("Hello, world!")
```
```javascript
console.log("Hello, world!");
```
```bash
echo "Hello, world!"
```
❌ Incorrect¶
🔧 Fixed¶
Note: The fix adds
textas a default language hint when none is specified.
Configuration¶
This rule has no configuration options.
Automatic fixes¶
This rule automatically adds text as the language specifier for code blocks without one.
Learn more¶
- CommonMark fenced code blocks - Technical specification
- GitHub Flavored Markdown - Language hints in code blocks