WMD Editor, Storing data as Markdown and not HTML

I recently had to add a Rich Text Editor to one of our applications and to one of my personal projects and I opted for WMD Editor, primarily because its a light weight, pure javascript based editor which takes less than 2 lines to install and configure. (Okay, there is no real installation its Javascript) and it lets me preview the text instantly without having to reload or open the formatted text on a separate window. I can’t understand how blog sites overlook this feature and something which stackoverflow has completely nailed. I see sites like Posterous not even providing a preview (if it does exists its well hidden).

The problem I encountered was storing data as HTML. I absolutely hate storing information as HTML and WMD Editor comes configured by default to return HTML data. So a bit of googling helped me figure out how to configure WMD to return Markdown instead of HTML.

You can always convert markdown to html using any simple plugin or gem, (I used RedCloth)

You can get WMD Editor from here

To configure the editor unzip the folder and open the wmd.js file and make the following changes

Attacklab.wmd_defaults = {version:1, output:"HTML", lineLength:40, delayLoad:false};

Change this to

Attacklab.wmd_defaults = {version:1, output:"markdown", lineLength:40, delayLoad:false};

and your good to go.

I found this bit on SO . Thanks to fiskfisk

Hope this is handy.

Edit update:

I just tried RDiscount and its much better than RedCloth and clearly they way to go.