Categories
SwiftUI

SwiftUI: Markdown support for string variables

struct MarkdownTest: View {
  var text: String = "**Hello** *World*"
  var body: some View {
    VStack {
      Text("**Hello** *World*") // will be rendered with markdown formatting
      Text(text) // will NOT be rendered according to markdown
    }
  }
}

Here how to fix.


      Text(.init(text)) // this renders markdown properly
    

Ref: https://developer.apple.com/forums/thread/683632