gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.44k stars 298 forks source link

Make blocknodes public #276

Closed kchro3 closed 10 months ago

kchro3 commented 10 months ago

Hey @gonzalezreal , I am loving your awesome library! Thanks for sharing it.

I have a use-case where I want to use the MarkdownContent parser and inspect the blocks. I want the app to behave differently if the markdown contains a codeblock, so I want to do something like:

let markdown = MarkdownContent(text)
if let codeBlock = markdown.blocks.first(...) {
   // do this
}

The problem is that BlockNode is not public, so I can't access it. I'm creating this fork as a workaround, but opening a PR in case you think it's worth exposing.

gonzalezreal commented 10 months ago

Hi @kchro3,

Thanks for your kind words! I prefer to keep the syntax tree model as an implementation detail. Please use your fork if that solves your use case.