swiftlang/swift-markdown

Question: how to convert Markup string to AttributedString

kvaDrug opened this issue · 3 comments

I have a simple question. Can you please explain briefly, how to convert a Markup string to AttributedString using this lib? Ideally, with a simple function call. I scrolled the documentation and found that it specialised on DOM model, which is overkill for my case. But probably the function I'm looking for is hidden somewhere.

Hi @kvaDrug, there is an AttributedString API in Foundation that takes a Markdown string: https://developer.apple.com/documentation/foundation/attributedstring/instantiating_attributed_strings_with_markdown_syntax. You don't need to import Swift-Markdown to use it.

@franklinsch, unfortunately it works only on iOS 15 or later. I'll consult my manager whether he want's to ditch 14. Meanwhile I'm looking for solution which is compatible with this version.

Hi @kvaDrug,

This is great example how to use it:
https://github.com/christianselig/Markdownosaur