I'm trying to show my response data using SwiftUI Text with formatted text ex: Bold, but for some reason it's not working 🤔
The needed behaviour as below:

This is working!
Text("**Hello** *World*")
But this is not 🤔
let text: String = "**Hello** *World*"
Text(text)
Am I missing something 🤔
After test and fail moments, I found that Text only handles markdown when string literal is passed to initializer. as below:
to achieve the needed behavior:
let text: String = "**Hello** *World*"
Text("**Hello** *World*") // will be rendered with markdown formatting
Text(text) // will NOT be rendered according to markdown
Text(.init(text)) // will be rendered with markdown formatting

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With