The CommonsBlog


CWAC-AndDown: Markdown for Android (and a plea for help)

I have started up another CWAC project, this one offering Markdown support for Android. In its current incarnation, it wraps around the sundown Markdown parser and makes it available to Android apps via the NDK. Parsing is very fast: converting ~5K of Markdown into HTML takes just a couple of milliseconds.

For those of you who are still trying to figure out what “Markdown” is (besides a term for me when I stumble and fall), Markdown is a wiki-type markup language, created by John Gruber of Daring Fireball fame. Markdown is the syntax you use for marking up questions and answers in StackOverflow, is an option in various blog and wiki engines, and is used in many places in GitHub.

Apps that consume existing Markdown code might use AndDown to convert the Markdown into something that can be presented in rich format. Right now, that would be by converting it to HTML, and handing that HTML to a WebView widget, or by using Html.fromHtml() to create a Spannable for use with a TextView.

The problem with the latter approach is that what AndDown does is inefficient: it converts Markdown to HTML (in native code), which is then parsed and converted into a Spannable (in firmware-supplied Java). Creating the HTML is fast; parsing and converting the HTML is slow.

Ideally, AndDown would support generating a Spannable straight from Markdown, in addition to the HTML-generation path. And that’s where I’m recruiting for a bit of NDK/JNI help. I’m OK at maintaining such code, but I have limited JNI experience, and my C development days are a distant, faded memory (puncutated by occasional nightmares).

I have a GitHub Wiki page set up with what I’m pondering in this area. If you have an interest in NDK/JNI and would like to help, drop me a line. I’m willing to do this on a contract basis, if you’d like to be paid for this work.

Later on, I plan to add to AndDown the reverse path, taking a SpannedString and creating equivalent Markdown-formatted text.


Need a speaker at your Android development meetup? Mark Murphy is available, in person in the Boston/Pittsburgh/DC triangle, or by remote anywhere in the world! Contact Mark for details!