Ad

Our DNA is written in Swift
Jump

DTMarkdownParser 0.2.0

DTMarkdownParser, our event-based parser for Markdown, has much progressed since 0.1.0. Since I will not be able to work on this as much in the coming weeks and it has reached a nice stable state I’m releasing this new development version.

Changes

  • CHANGED: Rewritten and cleaned up parsing loop to be able to handle links or references spanning two lines
  • ADDED: Mac Demo
  • ADDED: Inline linking via angle brackets
  • ADDED: Auto-Linking of URLs and email addresses using NSDataDetector
  • FIXED: Many edge cases

There was lots of cleaning up around the main parsing loop that needed to be done. In the previous version the parsed string was divided into lines and these got processed. This was causing problems with some use cases where hyperlinks and references could not be handled if they were spanning two lines. So I rewrote the main parse loop from scratch.

Since it is required to know when parsing the beginning of a line there is an array of ranges that make up the individual lines. The initial implementation was using NSRange values wrapped in NSValue objects. Friend of the project Jan Weiß proposed an optimisation using a C-array which sped up the parsing quite a bit. This became DTRangesArray.

Jan also put much work into a very useful demo application. He can be reached via Twitter or his blog at Geheimwerk.de.

DTMarkdownParser Mac Demo

The demo allows you to load, view and edit markdown files in the left pane. In the right you see a tree view, the raw source or a web view of HTML that is generated from the DTMarkdownParser events. Having this useful app available let me find several bugs which otherwise I wouldn’t have seen.

There are still some features not yet implemented, which could use your help if you are interested:

  • handling of character escaping
  • stacking of blockquotes inside other blockquotes or list items.
  • wiring up of range reporting for syntax highlighting
  • a plethora of extended Markdown features

The update is tagged on the master branch of the GitHub repo as well as available via CocoaPods.


Tagged as:

Categories: Updates

7 Comments »