gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.53k stars 318 forks source link

Add Markdown content to block configuration #220

Closed gonzalezreal closed 1 year ago

gonzalezreal commented 1 year ago

This pull request adds the block's Markdown content value to the block style configuration. This allows the block style to access the actual Markdown content rendered in the block style configuration label property.

You can use the renderMarkdown() and renderPlainText() methods on the content property to render the Markdown-formatted or plain text, respectively.

configuration.content.renderMarkdownText()
configuration.content.renderPlainText()

If you are styling a container block, like a list or a blockquote, you can access the child content using the childContent property.

configuration.content.childContent?.renderMarkdownText()

As a result of this change, all the block-style methods with a label closure are now deprecated. When creating new themes or overriding block styles, you should use the version of the method that takes a closure receiving a BlockConfiguration value.