Skip to content
Latchkey

markdownlint "MD040/fenced-code-language" in CI

markdownlint rule MD040 requires every fenced code block to declare a language after the opening fence, so syntax highlighting works. A bare ``` block fails the rule and the job exits non-zero.

What this error means

markdownlint reports "MD040/fenced-code-language Fenced code blocks should have a language specified" pointing at the opening line of a code fence.

markdownlint
docs/install.md:18 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]

Common causes

A code fence opens without a language

The block starts with bare triple backticks instead of, say, ```bash, so MD040 flags it.

Plain-text blocks still need an explicit tag

Even non-code output needs a language such as text or console to satisfy the rule.

How to fix it

Add a language to every fence

Tag each opening fence with the language, or text/console for plain output.

install.md
```bash
npm ci
```

```text
plain output that is not code
```

Allow a specific set of languages

Restrict MD040 to an allowed language list so typos in tags are also caught.

.markdownlint.json
{
  "MD040": { "allowed_languages": ["bash", "js", "ts", "json", "yaml", "text"] }
}

How to prevent it

  • Always tag fenced blocks with a language, using text for plain output.
  • Use allowed_languages to catch mistyped language tags.
  • Lint Markdown in pre-commit so untagged fences never reach CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →