---
date: 2021-02-08
tags: saga
summary: I've replaced the Ink and Splash dependencies with my own SwiftMarkdown package.
series: building-saga, Part 5
---

# Building my own static site generator, part 5: replacing Ink and Splash

_I've been designing and building my own static site generator, written in Swift, and an early version has been [released on Github](https://github.com/loopwerk/Saga). In this series of articles I want to go over the inspiration, the constraints and goals, how I got to my current API, and the pros and cons of said API. Finally, I also want to brainstorm about where to go from here._

All parts in this series:
%SERIES%
{.series}

In [part 3](/articles/2021/saga-3-thoughts-so-far/) I wrote about my thoughts on Saga so far, and a big take-away were the problems I found with the third party dependencies I initially chose for my static site generator Saga: [Ink](https://github.com/johnsundell/ink) and [Splash](https://github.com/JohnSundell/Splash) for the Markdown parsing and code highlighting, and the HTML template language [Stencil](https://github.com/stencilproject/Stencil).

In the past few days I've spent quite a lot of time looking at multiple Markdown libraries written in Swift, but sadly not a single one fulfilled all the requirements, like the parsing of metadata contained within a Markdown file or the ability to easily modify the output via extensions. The best Markdown parsers seemed to be written in Python, so I decided to use [PythonKit](https://github.com/pvieito/PythonKit) and wrote Swift wrappers around two promising Python libraries: [SwiftMarkdown](https://github.com/loopwerk/SwiftMarkdown) which wraps [Python-Markdown](https://github.com/Python-Markdown/markdown), and [SwiftMarkdown2](https://github.com/loopwerk/SwiftMarkdown2) which wraps [python-markdown2](https://github.com/trentm/python-markdown2). It's the first of these that I ended up using in Saga, because it was incredibly easy to extend that parser with my own extensions. For example, I want to strip the first title out of the Markdown "body", so that you can generate a summary from the body for example, or render the published date between the title and the body, like I do right here on this website.

It's not ideal that now Saga depends on Python and Python-Markdown, but the results simply speak for themselves: it's just a league above other parsers. If I find a pure Swift parser that can match this output, I'll gladly change over. I did keep my old Markdown reader that uses Ink and Splash as a [separate plugin](https://github.com/loopwerk/SagaInkMarkdownReader) which is easily installed and used instead of the new reader. That's a great thing about Saga; it's very easy to extend!

I'm happy to say that Saga is now able to generate my Loopwerk.io website without any meaningful changes in output. Even the old templates were ported over almost as-is. You can see [this Pull Request](https://github.com/loopwerk/loopwerk.io/pull/2) for details. Of course I'm still planning to replace Stencil with something completely different, so that PR will definitely grow to have bigger changes in the future.
