code
fun code(lang: String? = null, caption: String? = 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}
Content copied to clipboard
Parameters
lang
- Optional
- Likely named
optional language of the code
caption
- Optional
- Likely named
optional caption
linenumbers
- Optional
- Likely named
whether to show line numbers
focus
- Optional
- Likely named
range of lines to focus on. No lines are focused if unset. Supports open ranges. Note: HTML rendering requires linenumbers to be enabled.
code
- Likely a body argument
code content