Render iOS message markdown

This commit is contained in:
Mikhail Kilin
2026-05-21 15:37:04 +03:00
parent a0413f23b3
commit 419f409d98

View File

@@ -526,7 +526,7 @@ public struct MessageRow: View {
.font(.caption) .font(.caption)
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
} }
Text(message.text) Text(renderedText)
.textSelection(.enabled) .textSelection(.enabled)
if !message.reactions.isEmpty { if !message.reactions.isEmpty {
Text(message.reactions.map(\.emoji).joined(separator: " ")) Text(message.reactions.map(\.emoji).joined(separator: " "))
@@ -552,6 +552,17 @@ public struct MessageRow: View {
} }
} }
} }
private var renderedText: AttributedString {
(
try? AttributedString(
markdown: message.text,
options: AttributedString.MarkdownParsingOptions(
interpretedSyntax: .inlineOnlyPreservingWhitespace
)
)
) ?? AttributedString(message.text)
}
} }
public struct ComposeBar: View { public struct ComposeBar: View {