In the session, I have seen a lot of examples of rainbow effects and I'd like to bring it into my app written by SwiftUI, but one thing missing is that I'm not sure how to implement customizable markdown analysis and how to set the style for it. Please help me, maybe give me some ideas? or just some suggestions.
How can I customize markdown attribute?
What you need here is to create a new AttributeScope
that contains the AttributeKey
for your custom attribute, and pass that to the appropriate AttributedString(markdown:…)
or AttributedString(localized:…)
initializer. You can see that process in the What's New In Foundation session of WWDC '21.
Most AttributedString
constructors that take Markdown text have an including:
parameter that you can pass your scope type in.