include

fun include(src: String, linePattern: String = "", beginToken: String = "", endToken: String = "", exclusive: Boolean = true, trimIndent: Boolean = true, indentToken: String = INDENT_TOKEN, escapeHtml: Boolean = true): String

Load content from a local file or remote URL. Preferred over embedding code inline in slides because it avoids whitespace-sensitivity issues and lets you keep the source of truth in one place.

Intended for use inside markdownSlide { content { ... } } and htmlSlide { content { ... } } blocks. For com.kslides.slide.DslSlide use the include variant defined on DslSlide or kotlinx.html.CODE; those variants disable HTML escaping and the indentation token since the enclosing <code> tag handles both.

Return

the resolved content, or an empty string if reading fails (a warning is logged).

Parameters

src

local path (relative to the process working directory) or http(s):// URL. Paths containing ../ are rejected.

linePattern

optional reveal.js-style line range (e.g. "1-3|5") to restrict which lines are returned.

beginToken

if non-blank, only content after a line containing this token is returned.

endToken

if non-blank, only content before a line containing this token is returned.

exclusive

when true, the begin/end-token lines themselves are excluded from the output.

trimIndent

remove the common leading indentation from all returned lines.

indentToken

marker string the renderer uses to re-indent included lines to match the surrounding Markdown/HTML; set to "" in code contexts.

escapeHtml

HTML-escape the returned content; disable for kotlinx.html.CODE blocks that already own their escaping.

Throws

if src is a local path containing "../".


fun CODE.include(src: String, linePattern: String = "", beginToken: String = "", endToken: String = "", exclusive: Boolean = true, trimIndent: Boolean = true): String

include variant for use inside a <code> block. Disables the HTML escape + indent-token behavior (the <code> tag already controls both) and pads the result for reveal.js's line-number display.


fun DslSlide.include(src: String, linePattern: String = "", beginToken: String = "", endToken: String = "", exclusive: Boolean = true, trimIndent: Boolean = true): String

include variant for use inside a com.kslides.slide.DslSlide content{} block. Same semantics as CODE.include — HTML escaping and the indent token are turned off.