Grails Markdown Plugin 0.1 Released

2009/10/6

I’ve just released a quick plugin that I put together tonight to help render markdown text as HTML within a grails application. It leverages the MarkdownJ library.

I’m a big fan of storing information in markdown format as it is easy to read, easy to write, and easy to transform. A number of big websites like stackoverflow.com support the entry and display of markdown text to help people format their questions and answers without having to remember to properly format HTML.

If you’re unfamiliar with Markdown there are a number of good references on it’s use.

The grails markdown plugin is a very basic plugin. Currently, it just wraps the markdown libarary with a single TagLib that lets you easily render html from a markdown string within your gsp pages.

To install it, just type:

grails install-plugin markdown

To use it in your gsp file:

<markdown:renderHtml>
The *four* cardinal directions are
 
- North
- South
- East
- West
</markdown:renderHtml>

renders the html:

<p>The <em>four</em> cardinal directions are</p>
<ul>
    <li>North</li>
    <li>South</li>
    <li>East</li>
    <li>West</li>
</ul>

Or you can use the “text” attribute of the taglib:

<markdown:renderHtml text="${post.body}"/>

See the Grails Markdown Wiki and source for more details.


There are 3 comments in this article:

  1. 2009/10/16Dani Latorre say:

    Hi Ted,

    Great work! This week I started to work on a markdown plugin for a pet-project(I didn’t search for a plugin on google XD) and I have some code that maybe useful for your plugin.

    Using groovy ExpandoMetaClass I added a markdown2Html method on String class and a grails service for wrap the markdown library.

    I’m already a plugin contributor, if you think it is useful, send me an email and I’ll commit the code.

  2. 2009/10/18tednaleid say:

    Thanks Dani, your code sounds interesting. Is it something you could submit an issue for and either submit a patch, or attach your code so that I can take a look at it?

    I don’t store my plugins in SVN (due to a number of issues with the grails plugin repo).

  3. 2009/10/18tednaleid say:

    Just released the 0.2 version of the plugin with the patch file from Dani. Thanks for the patch (and tests!) Dani, I appreciate it.

Write a comment: