Common markdown lint rules and how to fix violations.
| Rule | Issue | Fix |
|---|---|---|
| MD026 | Trailing punctuation in heading | Remove :, ., ; from heading end |
| MD040 | Code block without language | Add language after opening ``` |
| MD058 | Table without blank lines | Add blank line before and after table |
Every fenced code block needs a language specifier.
Wrong:
```
some content here
```Correct:
```text
some content here
```Common language specifiers:
text- Plain text, diagrams, generic contentbashorshell- Shell commandsjson- JSON configurationyaml- YAML configurationjavascriptorjs- JavaScripttypescriptorts- TypeScriptpython- Pythonmarkdownormd- Markdown examples
Tables must have blank lines before and after them.
Wrong:
### Pricing Tiers
| Price | Rate |
|-------|------|
| $1.00 | 35% |Correct:
### Pricing Tiers
| Price | Rate |
|-------|------|
| $1.00 | 35% |Headings should not end with punctuation marks.
Wrong:
### When referencing concepts:
### Adding new items:Correct:
### When Referencing Concepts
### Adding New ItemsThe .markdownlint.json template includes these key settings:
{
"MD026": { "punctuation": ".,;:!" },
"MD040": true,
"MD058": true
}Some rules are disabled in the template for flexibility:
| Rule | Why Disabled |
|---|---|
| MD013 | Line length - too restrictive for documentation |
| MD022 | Blank lines around headings - conflicts with some patterns |
| MD033 | Inline HTML - sometimes necessary |
| MD041 | First line heading - not always applicable |
# Install
npm install -g markdownlint-cli2
# Run on all markdown files
markdownlint-cli2 "**/*.md" --config .markdownlint.json
# Exclude specific files
markdownlint-cli2 "**/*.md" "!CHANGELOG.md" --config .markdownlint.jsonThe markdown-lint.yml workflow template runs on all PRs:
- name: Lint markdown files
uses: DavidAnson/markdownlint-cli2-action@v22
with:
config: '.markdownlint.json'
globs: |
**/*.md
!CHANGELOG.mdWhen documenting in Serena memories or similar structured docs:
## Section Title
### Category Name
| Column 1 | Column 2 |
|----------|----------|
| Value | Value |
### Next CategoryNote the blank lines:
- After the section heading
- After the subsection heading (before table)
- After the table (before next heading)
### Example Usage
```bash
npm install package-name
```
### Configuration
```json
{
"key": "value"
}
```When you have many violations of the same rule:
- MD040 (code language): Search for
```followed by newline, addtext - MD058 (table spacing): Search for
|\n###or###\n|, add blank line - MD026 (trailing punctuation): Search headings ending with
:and remove