include

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.


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

include variant for a Markdown slide's content{} block, where reveal.js's Markdown renderer escapes its own output. Unlike CODE.include and DslSlide.include the indent token is kept, since Markdown content is re-indented to match the surrounding block.


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

include variant for an htmlSlide content{} block — the one sink whose content is still parsed as markup, so escaping stays on. Identical to the bare include; it exists so every sink is receiver-resolved, rather than htmlSlide being the one whose behavior comes from the absence of an overload.


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.

Escapes markup so the content renders as text. That is what htmlSlide { content { ... } } needs, and this overload is the one that resolves there. Elsewhere a destination-aware variant wins instead — see IncludeVariants.kt — because a <code> block, a dslSlide, and a markdownSlide each escape their own output, so content escaped here would reach the browser as a visible &quot;. Resolution is by the enclosing receiver, so the choice is not yours to make.

Return

the resolved content, or an empty string if the file/URL cannot be read (an I/O failure, missing file, or failed HTTP fetch — a warning is logged). Authoring errors such as an absent beginToken/endToken or a malformed linePattern are not swallowed; they propagate.

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

escape markup in the returned content so it renders as text rather than being interpreted; disable for kotlinx.html.CODE blocks that already own their escaping.

Throws

if src is a local path containing "../", or if a beginToken/endToken is not found, or if linePattern is malformed.