KwikiMarkdown

WebHome | UnixGeekTools | Geekfarm | About This Site

MarkDown and KwikiKwiki

Recently I upgraded to OS X 10.4. I decided to upgrade to the latest version of kwiki. Unfortunately my old markdown hacks were broken. So I decided to ditch my prototype and start from scratch, this time going it a completely different direction. This code is the result of the rewrite, which was done in a couple hours. I'll be fixing bugs as I find them.

Basically I just created a custom Kwiki::Display module. Just place it in lib/Kwiki/Display.pm and it will be used in place of the default one. You will also need to have Markdown installed.

The real problem with using MarkDown for a wiki is that MarkDown doesn't handle wiki words or other common wiki link conventions, e.g. bracketed links, making urls into links, and making image urls into images to be displayed inline. Since I access my wiki files through both kwiki and emacs wiki, I needed those to work.

In order to avoid writing lots of really ugly regular expressions, I decided to follow a trick i read about on the web. Each time the parser encounters something that looks like a link, it removes the link from the text and computes the md5 of the text and replaces the link with the md5. Once all the links have been neatly removed, the text is sent to markdown for formatting. Finally, after markdown is done, then all the md5s are found and replaced with their links. This makes the parsing fu crazy simple.

Currently it's impossible to deactivate links for wiki words or even in verbatim sections. This is still alpha. Expect to see bugs.

For more details, see the inline docs.

Download

http://www.geekfarm.org/wu/kwiki/Display.pm

Pointers

- WebHome




Updated Sun Jul 23, 2006 12:12 PM