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

TextSpan

Spans carry text and optional per-span styling, links, and fenced-code metadata into TextLayout. A nil style uses the painting fallback. Non-copyable spans remain visible but are excluded from copied selections. TextLayout sanitizes controls when combining spans.

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 spans = [TextSpan("Hello "), TextSpan("Swift", style: Style(bold: true))]
_ = TextLayout(spans, width: 40, wrapping: .word)
Members on this page

Feature guides and release status

TextSpan

Structure
struct TextSpan

Conforms to: Swift.Sendable, Swift.SendableMetatype.

A source-text segment with an optional style override.

A nil style inherits the paragraph's style; a supplied style replaces it. The optional patch then modifies that resolved appearance. Adjacent spans remain one continuous source string for layout, selection, and copying.

Source · TextSpan.swift:6

sourceLine

Instance Property
let sourceLine: Int?

One-based Markdown source line for the first character, when supplied.

Synthetic presentation prefixes have no source location.

Source · TextSpan.swift:10

text

Instance Property
let text: String

The stored text content.

Source · TextSpan.swift:11

style

Instance Property
let style: Style?

Visual attributes used when painting this value.

Source · TextSpan.swift:12

patch

Instance Property
let patch: StylePatch?

Changes applied after the span or inherited paragraph style.

Source · TextSpan.swift:14

codeBlock

Instance Property
let codeBlock: TextCodeBlock?

The original code represented by this span's block, when supplied by the renderer.

Source · TextSpan.swift:18

isCodeBlockHeader

Instance Property
let isCodeBlockHeader: Bool

Marks a dedicated code-block header row for application-owned controls.

Source · TextSpan.swift:20

copyable

Instance Property
let copyable: Bool

Display-only text remains visible but is omitted from copied selections.

Source · TextSpan.swift:22