code

.code   lang:{String? = null} \
caption:{InlineMarkdownContent? = null} \
linenumbers:{Boolean = true} \
focus:{Range? = null} \
ref:{String? = null} \
code:{EvaluableString}
-> Node

Creates a code block. Contrary to its standard Markdown implementation with backtick/tilde fences, this function accepts function calls within its code argument, hence it can be used - for example - in combination with read to load code from file.

Example of a code block loaded from file via read:

.code lang:{kotlin} focus:{2..5}
.read {snippet.kt}

Parameters

lang
  • Optional

optional language of the code

caption

optional caption

linenumbers
  • Optional

whether to show line numbers

focus
  • Optional

range of lines to focus on. No lines are focused if unset. Supports open ranges. Note: HTML rendering requires linenumbers to be enabled.

ref
  • Optional

optional identifier for cross-referencing this code block elsewhere via reference

code

code content