Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MD048 - Code Fence Style

Code fence style should be consistent.

Why This Rule Exists

Markdown supports two fence styles: backticks and tildes. Consistent style throughout a document improves readability and maintainability.

Styles

Backticks (Common)

```rust
let x = 1;
```

Tildes

~~~rust
let x = 1;
~~~

Examples

Incorrect (Mixed)

```python
print("Hello")
```

~~~bash
echo "World"
~~~

Correct

```python
print("Hello")
```

```bash
echo "World"
```

Configuration

[MD048]
style = "backtick"  # Options: "backtick", "tilde", "consistent"
ValueDescription
backtickUse triple backticks
tildeUse triple tildes
consistentMatch first fence's style

When to Disable

  • Documents with intentional style mixing
  • Content with nested code blocks (tildes inside backticks)

Rule Details

  • Rule ID: MD048
  • Aliases: code-fence-style
  • Category: Formatting
  • Severity: Warning
  • Auto-fix: Yes

Nesting Code Blocks

To show code fences inside code blocks, use different styles:

````markdown
```rust
let x = 1;
```
````
  • MD031 - Blanks around fences
  • MD040 - Fenced code blocks language
  • MD046 - Code block style