I’d like to use Markdown text in a UITextView. It looks simple, but I’m not getting the expected rendering of most elements.
<code>let mdString = """
# Headline
This is a line.
* Bullet 1
* Bullet 2
* Bullet 3
**strong text**
## Smaller Headline
[A link to Apple](https://www.apple.com)
"""
let options = AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace) as __NSAttributedStringMarkdownParsingOptions
guard let md = try? NSAttributedString(__markdownString: mdString, options: options, baseURL: nil) else {return}
instructionsTextView.attributedText = md
</code>
<code>let mdString = """
# Headline
This is a line.
* Bullet 1
* Bullet 2
* Bullet 3
**strong text**
## Smaller Headline
[A link to Apple](https://www.apple.com)
"""
let options = AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace) as __NSAttributedStringMarkdownParsingOptions
guard let md = try? NSAttributedString(__markdownString: mdString, options: options, baseURL: nil) else {return}
instructionsTextView.attributedText = md
</code>
let mdString = """
# Headline
This is a line.
* Bullet 1
* Bullet 2
* Bullet 3
**strong text**
## Smaller Headline
[A link to Apple](https://www.apple.com)
"""
let options = AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace) as __NSAttributedStringMarkdownParsingOptions
guard let md = try? NSAttributedString(__markdownString: mdString, options: options, baseURL: nil) else {return}
instructionsTextView.attributedText = md
This is the result:
Without the options as shown, the text renders as one long line but otherwise identical.
I’m interested in rendering the other format types.