Saga icon indicating copy to clipboard operation
Saga copied to clipboard

Create a markdown reader based on Apple's swift-markdown

Open kevinrenskers opened this issue 1 year ago • 0 comments

Apple's swift-markdown has been around for a while, and it's pretty interesting since it makes it quite easy to modify the AST of the parsed markdown. Parsley in contrast doesn't allow you to modify the HTML, see https://github.com/loopwerk/Parsley?tab=readme-ov-file#modifying-the-generated-html:

Parsley doesn't come with a plugin system, it relies purely on cmark-gfm under the hood to render Markdown to HTML. If you want to modify the generated HTML, for example if you want to add target="blank" to all external links, SwiftSoup is a great way to achieve this. Adding a plugin system on top of cmark would mean that Parsley could no longer rely on the outstanding output of cmark; instead Parsley would have to parse its AST and generate HTML based on that itself, thus reinventing the (very complex) wheel.

The problem with swift-markdown was that it didn't include an HTML renderer, and as such pretty much useless for Saga (or any other web-based projects). It's why I created Parsley.

However, the next release of swift-markdown does have an HTMLFormatter and thus ripe for Saga. At the moment this feature is unreleased on the main branch, and they won't create a new release/tag until the next Swift 6.x release.

kevinrenskers avatar Feb 19 '25 23:02 kevinrenskers