MyST Markdown

# Code and code-blocks

You can include code in your documents using the standard markup syntax of language, where language is the programing language for highlighting.

## #Code blocks

The above code is not a directive, it is just standard markdown syntax, which cannot add a caption or label. To caption or label blocks of code use the code-block directive.

## #Numbering and Highlighting

To add numbers and emphasis to lines, we are following the sphinx code-block directive. You can use linenos which is a flag, with no value, and emphasize-lines with a comma-seperated list of line numbers to emphasize.

You can also set the start number using the lineno-start directive, and all emphasized lines will be relative to that number.

## #code-block reference

linenos (no value)

Show line numbers for the code block

lineno-start (number)

Set the first line number of the code block. If present, linenos option is also automatically activated.

Default line numbering starts at 1.

emphasize-lines (string)

Emphasize lines of the code block, for example, 1, 2 highlights the first and second lines.

The line number counting starts at lineno-start, which is by default 1.

caption (string)

Add a caption to the code block.

name (string)

The target label for the code-block, can be used by ref and numref` roles.

MyST Tools
MyST Markdown Tools
Documentation