Understand the Textual rendering pipeline
mainTextual transforms markup into rendered SwiftUI UI through a five-stage pipeline. Understanding this flow is essential for customizing how content is parsed, styled, or displayed:
- Parsing: Converts markup into an
AttributedStringusing aMarkupParser. It usesPresentationIntentfor blocks and Foundation attributes for inline formatting. - Resolving attachments: Asynchronously loads references (like image URLs) and writes them back into the
AttributedStringasTextual.Attachmentattributes. - Styling: Applies inline styles (via
WithInlineStyle) usingTextEnvironmentValuesand groups runs into block-specific views (viaBlockContent). - Building: Uses
TextBuilderto construct SwiftUITextobjects. It creates invisible placeholders for attachments based on their size proposals. - Overlaying: Uses resolved
Text.Layoutgeometry to position attachment views and handle link interactions or text selection.