2022-10-30 15:13:19 -07:00
|
|
|
# `MD040` - Fenced code blocks should have a language specified
|
2022-10-29 23:21:45 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `code`, `language`
|
2022-10-29 23:21:45 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `fenced-code-language`
|
2022-10-29 23:21:45 -07:00
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
* `allowed_languages`: List of languages (`string[]`, default `[]`)
|
|
|
|
|
|
|
|
This rule is triggered when fenced code blocks are used, but a language isn't
|
|
|
|
specified:
|
|
|
|
|
|
|
|
````markdown
|
|
|
|
```
|
|
|
|
#!/bin/bash
|
|
|
|
echo Hello world
|
|
|
|
```
|
|
|
|
````
|
|
|
|
|
|
|
|
To fix this, add a language specifier to the code block:
|
|
|
|
|
|
|
|
````markdown
|
|
|
|
```bash
|
|
|
|
#!/bin/bash
|
|
|
|
echo Hello world
|
|
|
|
```
|
|
|
|
````
|
|
|
|
|
|
|
|
To display a code block without syntax highlighting, use:
|
|
|
|
|
|
|
|
````markdown
|
|
|
|
```text
|
|
|
|
Plain text in a code block
|
|
|
|
```
|
|
|
|
````
|
|
|
|
|
|
|
|
You can configure the `allowed_languages` parameter to specify a list of
|
2022-11-06 01:41:27 +01:00
|
|
|
languages code blocks could use. Languages are case sensitive. The default value
|
|
|
|
is `[]` which means any language specifier is valid.
|
2022-10-29 23:21:45 -07:00
|
|
|
|
|
|
|
Rationale: Specifying a language improves content rendering by using the
|
|
|
|
correct syntax highlighting for code. More information:
|
|
|
|
<https://cirosantilli.com/markdown-style-guide#option-code-fenced>.
|