summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Extensions/AttributedString+Helpers.swift
diff options
context:
space:
mode:
Diffstat (limited to 'ios/MullvadVPN/Extensions/AttributedString+Helpers.swift')
-rw-r--r--ios/MullvadVPN/Extensions/AttributedString+Helpers.swift16
1 files changed, 16 insertions, 0 deletions
diff --git a/ios/MullvadVPN/Extensions/AttributedString+Helpers.swift b/ios/MullvadVPN/Extensions/AttributedString+Helpers.swift
new file mode 100644
index 0000000000..1e2bd4b5ac
--- /dev/null
+++ b/ios/MullvadVPN/Extensions/AttributedString+Helpers.swift
@@ -0,0 +1,16 @@
+//
+// AttributedString+Helpers.swift
+// MullvadVPN
+//
+// Created by Andrew Bulhak on 2025-08-22.
+// Copyright © 2025 Mullvad VPN AB. All rights reserved.
+//
+
+import SwiftUI
+
+extension AttributedString {
+ /// Construct an AttributedString from text assumed to be in Markdown. If Markdown parsing fails, constructs one treating the text as plain text.
+ static func fromMarkdown(_ markdown: String) -> AttributedString {
+ (try? AttributedString(markdown: markdown)) ?? AttributedString(markdown)
+ }
+}