Code

Syntax-highlighted code block and folder explorer.

Code Block Showcase Controls

Group multiple code blocks into an IDE-like folder explorer.

greeting.ts

Use a single code block for short examples.

Usage#

Code Block#

Write a fenced code block with a language for syntax highlighting.

Header#

Add a filename in square brackets to show a header, or omit it for a headerless block.

Line Numbers#

Set lineNumbers=true to show line numbers.

Line Highlights & Diffs#

Use added, deleted, and highlighted ranges to highlight particular lines.

Compact#

Set compact=true to align the block's borders with the text column without changing its inner padding. This only affects standalone blocks on desktop.

Code Group#

Wrap related code blocks in CodeBlockGroup. File paths dictate the folder structure.

Set the group's lineNumbers to true to enable numbers for every file, or false to hide them. Each fence keeps its own annotation ranges.

Code Block Reference#

filenameDefault undefined
string

File path shown in the header. Omit for a headerless block.

languageDefault undefined
string

Syntax-highlighting language. Omit for plain text.

lineNumbersDefault false
boolean

Show line numbers. A group controls this for all its files.

compactDefault false
boolean

Align borders with the content column without changing inner padding. Only affects standalone blocks on desktop.

addedDefault undefined
string

One-based line ranges tinted with the positive color role.

deletedDefault undefined
string

One-based line ranges tinted with the negative color role. Text remains available for copying.

highlightedDefault undefined
string

One-based line ranges tinted with the accent color role. Each line can have only one annotation.

Code Group Reference#

lineNumbersDefault false
boolean

Display line numbers for every fence in the group.