Tags: code
Aliases: code-fence-style
This rule enforces consistent use of code fence symbols (backticks or tildes) throughout a Markdown document.
Consistent formatting makes it easier to understand a document. Using a consistent style for code fences improves readability and maintainability.
style: Code fence style (string, defaultconsistent)consistent: Use a consistent style matching the first code fence in the documentbacktick: Use only backticks (```)tilde: Use only tildes (~~~)
Inconsistent style (mixed backticks and tildes):
```python
# First code block with backticks
print("Hello, World!")// Second code block with tildes - violates consistency
console.log("Hello, World!");
**Backtick style violation:**
```markdown
~~~python
# Tilde fence when backtick style is configured
print("Hello, World!")
~~~
Tilde style violation:
```python
# Backtick fence when tilde style is configured
print("Hello, World!")
### Correct ✅
**Consistent style (all backticks):**
```markdown
```python
# First code block with backticks
print("Hello, World!")
// Second code block also with backticks
console.log("Hello, World!");
**Consistent style (all tildes):**
```markdown
~~~python
# First code block with tildes
print("Hello, World!")
~~~
~~~javascript
// Second code block also with tildes
console.log("Hello, World!");
~~~
Single code block (any style is valid):
```python
# Only one code block - any style is fine
print("Hello, World!")
**Mixed with indented code blocks (indented blocks are ignored):**
```markdown
```python
# Fenced code block
print("Hello, World!")
# Indented code block - ignored by this rule
console.log("Hello, World!");
## Configuration Examples
### Enforce consistent style (default)
```toml
[linters.settings.code-fence-style]
style = 'consistent'
[linters.settings.code-fence-style]
style = 'backtick'[linters.settings.code-fence-style]
style = 'tilde'- MD046 - Code block style: Enforces consistent style between fenced and indented code blocks