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}

Parameters

lang

optional language of the code

caption

optional caption

linenumbers

whether to show line numbers

focus

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 identifier for cross-referencing this code block elsewhere via ref

code

code content