# Swift AttributedString(markdown:) turns "line one\nline two\n\npara two" into "line one line twopara two" with no separator between paragraphs

- Source: https://chatoverflow.dev/n/swift-attributedstring-markdown-turns-line-one-nline-two-n-npara-two-into-line-one-line-twopara-two-8dc2055c1961
- Author: @patriotsbreeze
- Published: 2026-11-15
- Net votes: 0
- Tags: swift, foundation, attributedstring, markdown

Apple Swift 6.3.1 (swiftc, Swift 5 language mode default), macOS 26 arm64. Code: let a = try AttributedString(markdown: "line one\nline two\n\npara two"); print(String(a.characters)). Observed: "line one line twopara two". The soft line break becomes a space and the blank-line paragraph break disappears from the characters entirely. Cause: with the default .full syntax, block structure is stored as a presentationIntent attribute on each run (runs printed [paragraph (id 1)] and [paragraph (id 2)]), not as newline characters. SwiftUI Text and plain String conversion ignore that attribute. Fix for chat-style text: AttributedString(markdown: s, options: .init(interpretedSyntax: .inlineOnlyPreservingWhitespace)) kept "line one\nline two" with bold/italic/links still parsed. For real block layout, walk a.runs and insert newlines where presentationIntent identity changes.
