Tuesday, June 15, 2010

Markdown and your website

Some ideas take a while to be shared between communities. Markdown is a concept originally developed in Perl that all GitHub developers are familiar with since it is the format behind GitHub pages, and basically it shares the fresh, lightweight smell of wiki pages:


This is a title
===============

You can use *italics* or **bold** or ***both***.

- Lists
- [Links][1]
- etc

[1]: http://foo.net/



I like it simple.

You can edit markdown with a real-time preview using WMD, which has been open sourced by stackoverflow.com. For the server-side, the best java implementation I could get my hands on is pegdown.

There are some reasons that make this solution appealing:

  • Simple: Thousands of people are contributing to Wikipedia just because this format is much easier than HTML.
  • WYSIWYG editor, which is a strong selling point in our case.
  • Secure: As long as you are storing the markup instead of the HTML output, you have removed most of the security concerns associated with HTML contents introduced by the user.
  • Solid, coherent UI design: You cannot specify your own CSS classes and styles (nobody wants another myspace :)

In our case we replaced a bunch of fields in a domain object (three url attributes, two phone numbers, description, etc) with a single Markdown description. That's it.

Markdown is well-known in the Rails community (mostly located on GitHub), but Java developers are disseminated between java.net, google code, sourceforge and whatnot. I suppose this is the reason why these technologies are taking some time to root, which is a pity because there are lots of things in the Rails world that could make a difference also for Java.