Formatting

Code blocks

Block styles, labels, syntax detection, aliases, wrapping and line numbering.

Block styles

Value of --code-block-style Presentation
basic Indented code without a border; the default.
simple A single left gutter.
pretty A box-drawn frame.

Append :show-name, :show-icon or :show-name;show-icon to show a title. Both are hidden by default. Icons need a Nerd Font; plain language names do not.

Code block frame

mdv --no-config --theme catppuccin --cols 64 --code-block-style basic example.md
mdv outputVersion 6.1.1
  fn main() {
      println!("hello, mdv");
  }
Markdown source
```rust
fn main() {
    println!("hello, mdv");
}
```

Code labels and icons

Hidden labels, a language name, an icon, or both.

mdv --no-config --theme catppuccin --cols 64 --code-block-style pretty example.md
mdv outputVersion 6.1.1
╭─────────────────────────────╮
│ fn main() {                 │
│     println!("hello, mdv"); │
│ }                           │
╰─────────────────────────────╯
Markdown source
```rust
fn main() {
    println!("hello, mdv");
}
```

Code line numbers

Numbering restarts for each block. A bare --code-line-numbers numbers rendered rows, including wrapped continuations. source numbers physical code lines and leaves continuation rows unnumbered. separator adds a separator. The options combine as source;separator and work in all three styles.

Code line numbers

mdv --no-config --theme catppuccin --cols 44 example.md
mdv outputVersion 6.1.1
  fn main() {
      let message = "A long line of code tha
        t wraps to the available terminal wi
        dth";
      println!("{message}");
  }
Markdown source
```rust
fn main() {
    let message = "A long line of code that wraps to the available terminal width";
    println!("{message}");
}
```

Wrapped-line indentation

--wrap chooses code breakpoints. --code-wrap-indent controls continuation rows: none adds no hanging indent, base preserves the original indentation, and double adds two spaces to the original indentation (the default). Gutters, frames, margins and enclosing lists reduce available width before wrapping.

Code continuation indent

mdv --no-config --theme catppuccin --cols 44 --code-wrap-indent none example.md
mdv outputVersion 6.1.1
  fn main() {
      let message = "A long line of code tha
  t wraps to the available terminal width";
      println!("{message}");
  }
Markdown source
```rust
fn main() {
    let message = "A long line of code that wraps to the available terminal width";
    println!("{message}");
}
```

Language detection and syntax colors

mdv uses the language hint, custom aliases and built-in aliases before trying heuristic detection.

  • --no-code-guessing keeps unknown blocks as plain text.
  • Explicit plain/Markdown blocks use their own text path.
  • Custom syntax definitions add new languages; themes control code colors independently from document colors.

Language guessing

mdv --no-config --theme catppuccin --cols 64 example.md
mdv outputVersion 6.1.1
  #!/usr/bin/env python3
  def greet(name):
      print(f"Hello, {name}!")
  greet("mdv")
Markdown source
```
#!/usr/bin/env python3
def greet(name):
    print(f"Hello, {name}!")
greet("mdv")
```

Custom icons, labels and aliases

--custom-code-block uses language:icon=...,label=...,aliases=... entries separated by ;. Separate properties with commas and aliases with |. default:icon=... sets the unknown-language icon. These definitions change labels and lookup aliases, not the syntax grammar.

Custom code labels

mdv --no-config --theme catppuccin --cols 64 --code-block-style 'pretty:show-name;show-icon' example.md
mdv outputVersion 6.1.1
╭─  Rust ────────────────────╮
│ fn main() {                 │
│     println!("hello, mdv"); │
│ }                           │
╰─────────────────────────────╯
Markdown source
```rust
fn main() {
    println!("hello, mdv");
}
```
custom_code_block:
  python:
    icon: "*"
    label: Python
    aliases: [py, py3]
  default:
    icon: "?"

Omitted properties merge with lower-priority settings.

  • null clears a property or entry; root null or {} clears the entire custom setting.
  • aliases: [] or CLI aliases=[] clears inherited aliases.
  • Code titles use code_block.label, and frames use code_block.border in the theme schema.