Code and code-blocks
You can include code in your documents using the standard markup syntax of
where language is the programing language for highlighting.
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
#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.
- linenos (no value)
Show line numbers for the code block
- lineno-start (number)
Set the first line number of the code block. If present,
linenosoption is also automatically activated.
Default line numbering starts at
- emphasize-lines (string)
Emphasize lines of the code block, for example,
1, 2highlights the first and second lines.
The line number counting starts at
lineno-start, which is by default
- caption (string)
Add a caption to the code block.
- name (string)
The target label for the code-block, can be used by