PreprocessedContent is a nested class within MarkdownTextView that encapsulates preprocessed markdown content including parsed block nodes, rendered math equations, syntax-highlighted code, and image sources.
Class Definition
Properties
Array of parsed markdown block nodes representing the document structure.
Map of rendered math content keyed by replacement text identifiers. Type alias for
[String: RenderedTextContent].Map of syntax highlighting color ranges for code blocks, keyed by content hash.
Initializers
Empty Initializer
Creates an empty preprocessed content instance.Manual Initializer
Creates preprocessed content with manually provided components.Array of parsed markdown block nodes.
Map of rendered math content.
Map of syntax highlighting data for code blocks.
Set of image source URLs to preload.
Parser Result Initializer
Creates preprocessed content from a parser result. Performs both code highlighting and math rendering on the calling thread.The parser result containing the markdown document.
The theme to use for rendering and highlighting.
Background-Safe Initializer
Creates preprocessed content with code highlighting done on the calling thread and math rendering deferred. Use this from background queues where UIKit trait access is unavailable.The parser result containing the markdown document.
The theme to use for rendering and highlighting.
If
true, defers math rendering for later completion on the main thread. Code highlighting is performed immediately as it’s thread-safe.When
backgroundSafe is true, you must call completeMathRendering(parserResult:theme:) on the main thread to finish math rendering.Methods
completeMathRendering
Fills in math-rendered content from the main thread after background initialization. Use this to complete preprocessing started with thebackgroundSafe initializer.
The parser result used during initial preprocessing.
The theme to use for math rendering.
A new PreprocessedContent instance with math rendering completed.
Type Aliases
RenderedTextContent.Map
CodeHighlighter.HighlightMap
Usage Patterns
Simple Synchronous Usage
Background Processing with Deferred Math Rendering
Manual Construction
Performance Considerations
- Code highlighting is thread-safe and can be performed on background queues
- Math rendering requires main thread access for UIKit trait collection
- Images are automatically preloaded asynchronously when PreprocessedContent is created
- The
backgroundSafeinitializer pattern enables optimal background processing