Markdown Deep
Markdown Deep

My first attempt at porting code from C# to Swift

A long lime ago, I bought an app for the iPad that let me create outlines. Not a spectacular app, not a complicated app, but an app that did almost everything I wanted.

Only thing it didn't do that I desperately wanted was print. So I wrote a Windows application to print the outline. Since I was writing a Windows application, I thought I might as well add support for Markdown. The iPad app wouldn't support it, but it was primarily for formatting output to print or web, so it felt like a right addition.

That's where I found MakrdownDeep and added it to my project. It's been a wonderful addition and gave me all the Markdown functionality I needed.

Then I started down the lines of creating a Mac version and the world fell apart as I discovered several Markdown libraries, but none as comprehensive as MarkdownDeep. What is a bloke to do in these circumstances, but convert the C# code in GitHub to SWIFT.

It took me two months, but I ended up with a working copy of MarkdownDeep written entirely in SWIFT. It was a real eye opener of a project, but I got there and ended up with many hundreds of passing tests.

What it looks like

And the end result is...

The premise is simple; take some markdown:

Markdown code

Run it through the converter:

Markdown Transform

Get HTML out the other end:

Transformed HTML

Most markdown processors I have seen use very complex Regex statements to transform the markdown to HTML. I tend to find complex Regex rather hard to comprehend, especially when I've not looked at them for a while. This conversion appealed because it does it old school with string handling. It is, undoubtedly, slower but a lot simpler to maintain and a lot more predictable in it's output.

Source code

No secrets here

If anyone wants to take a look at the code, it's up on GitHub in my Markdown Deep Swift repo.

I have a performance issue to deal with at some point, but that is me being picky rather than a show stopper. It only affects really large document conversions and is probably down to my clumsy string handling conversions. It's mostly a case of finding the time to look at it.

I expect that, as my comfort and experience with Swift increase, I will revisit this code and do the tweaks it deserves.


Am I really any good?

Don't take my word for my abilities, take a look at other peoples opinions about me.