Post

Replies

Boosts

Views

Activity

New lines not being rendered in SwiftUI's markdown
I'm trying the new markdown functionality in SwiftUI but it seems that trying to render markdown from an Attributed String inside a variable strips away any new lines. This isn't the case when placing the raw markdown directly in the Text View's initialiser, as shown in the preview below. Is this a bug or is there a way to retain new lines when using Attributed String? None of the options seem to help. Thanks! import SwiftUI struct markdown_test: View {     let attStr = try! AttributedString(markdown: """ Hello **World** 👋🏻      \n\n\n\n [This is a test](www.google.co.uk) """)     var body: some View {         VStack(alignment: .leading) {             Text(attStr)             Text("Hello **World** 👋🏻\n[This is a test](www.google.co.uk)")         }     } }
3
3
10k
May ’22
New lines not being rendered in SwiftUI's markdown
I'm trying the new markdown functionality in SwiftUI but it seems that trying to render markdown from an Attributed String inside a variable strips away any new lines. This isn't the case when placing the raw markdown directly in the Text View's initialiser, as shown in the preview below. Is this a bug or is there a way to retain new lines when using Attributed String? None of the options seem to help. Thanks! import SwiftUI struct markdown_test: View {     let attStr = try! AttributedString(markdown: """ Hello **World** 👋🏻      \n\n\n\n [This is a test](www.google.co.uk) """)     var body: some View {         VStack(alignment: .leading) {             Text(attStr)             Text("Hello **World** 👋🏻\n[This is a test](www.google.co.uk)")         }     } }
Replies
3
Boosts
3
Views
10k
Activity
May ’22