loom & weft
Made for Swift.

Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.

LOOM Unreleased (PR #2) / TEXT, MARKDOWN, AND EDITING

TextCodeBlock

Metadata retaining the original fenced code, its optional language, identity, and compact presentation flag. TextSpan and TextLayout.Line use it to preserve code-panel information. An id identifies a code block within the rendered content.

Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.

Example

let code = TextCodeBlock(id: 0, language: "swift", code: "print(1)")
let span = TextSpan("print(1)", codeBlock: code)
_ = TextLayout([span], width: 40)
Members on this page

Feature guides and release status

TextCodeBlock

Structure
struct TextCodeBlock

Conforms to: Swift.Equatable, Swift.Sendable, Swift.SendableMetatype.

Original code associated with one Markdown block, independent of display wrapping.

Source · TextCodeBlock.swift:2

id

Instance Property
let id: Int

A source-byte identity that remains stable as text is appended to the Markdown source.

Source · TextCodeBlock.swift:4

language

Instance Property
let language: String?

Optional fenced-code language identifier.

Source · TextCodeBlock.swift:5

code

Instance Property
let code: String

Code without fences or presentation prefixes, retaining source whitespace.

Source · TextCodeBlock.swift:7

isCompact

Instance Property
let isCompact: Bool

Indicates that the layout reserves a compact summary instead of displaying code.

Source · TextCodeBlock.swift:9

init(id:language:code:isCompact:)

Initializer
init(id: Int, language: String? = nil, code: String, isCompact: Bool = false)

Creates a value with the supplied arguments. Default arguments are shown in the declaration.

Parameters (4)
id
Stable entry/icon identity, not an array index.
language
Argument type and any default are shown in the declaration; see the behavior notes above.
code
Argument type and any default are shown in the declaration; see the behavior notes above.
isCompact
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · TextCodeBlock.swift:11