code
.code lang:{String? = null} \
caption:{InlineMarkdownContent? = null} \
linenumbers:{Boolean = true} \
focus:{Range? = null} \
callouts:{Map<String, Any> = emptyMap()} \
ref:{String? = null} \
code:{EvaluableString}
-> NodeCreates 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}callouts can be specified to annotate specific lines of code with additional information:
.code lang:{javascript} callouts:{
- 1: Declares the function.
- 3: Builds the greeting.
}
function greet() {
const name = "World";
return `Hello, ${name}!`;
}As a Code primitive, this function can be used in .extend to affect every code block in the document, including those introduced by the standard triple-backtick and triple-tilde fences:
.extend {code} where:{lang: .lang::equals {javascript}}
.super linenumbers:{no}Parameters
- Optional
optional language of the code
- Optional
- Likely named
optional caption
- Optional
whether to show line numbers
- Optional
range of lines to focus on (1-based). No lines are focused if unset. Supports open ranges. Note: HTML rendering requires linenumbers to be enabled.
- Optional
- Likely named
optional dictionary of callout content, associated to their 1-based line number. Note: HTML rendering requires linenumbers to be enabled.
- Optional
optional identifier for cross-referencing this code block elsewhere via reference
- Likely a body argument
code content