Code blocks with and without a language
code-fence-language-mixon by default (info)Japanese / English
A code block without a language among blocks that name theirs
Example
How to fix
Add the language after the opening ```. For output or plain text, write "text".
Why it matters
A language on a code block (```bash, ```json) gives it highlighting on the reader's screen and says at a glance what it is. When most blocks name their language and a few do not, those few show plain and look forgotten. chaff does not decide which way to go; it points at the fewer (markdownlint's MD040 asks for a language on every block).
What it does not flag
Indented code blocks, blocks inside a quotation, and blocks that hold only a format template (<MAJOR>.<MINOR>.<PATCH>) are not read. When more than {limit} blocks lack a language, or they are as many as those with one, it is taken as a choice and not reported.
Turning it off or relaxing it
Technical details
- Layer
- L1
- Status
- stable
- Severity
- info
- Languages
- Japanese and English
- Suited to
- technical, docs, blog, legal, academic, literature, speech
- Reads from the document
- markdown
Levels
Set a level for this rule under rules in chaff.yaml. With nothing set, it runs at the level its genre gives it (see By genre below).
| strict | reported when 3 or fewer blocks lack a language and they are fewer than those with one |
|---|---|
| normal | reported when 2 or fewer blocks lack a language and they are fewer than those with one |
| relaxed | reported when 1 or fewer blocks lack a language and they are fewer than those with one |
By genre
- Runs by default in
- technical/spec, technical/readme, blog/tech, blog/essay, blog/owned-media, docs/manual, docs/faq, docs/glossary
- Turned off by the genre in
- legal/contract, legal/statute, legal/judgment, legal/patent, academic/paper, literature/fiction, literature/essay, literature/poetry, literature/play, speech/address, speech/transcript
- Not suited to, and not run in
- business/proposal, business/report, business/email, business/press-release, business/meeting-notes
Message
This code block names no language, unlike the others ({tagged} blocks name one)
Rewrite depth (chaff fix-plan --depth): light — words and sentences; the structure and the voice stay
This page is built from the rule's definition file:packages/chaff/rules/code-fence-language-mix.yaml