Wiki

Clone wiki

grails-markdown / Home

Grails Markdown Plugin

This is a quick plugin that leverages MarkdownJ to provide markdown taglib support within grails.

Markdown is simple, human readable, lightly formatted text that is easy to transform into HTML. It's great for rendering text that humans type into entry boxes to the screen.

Installation

Easy! In the root of your grails app, just execute:

grails install-plugin markdown

Usage

The plugin currently provides a single taglib, markdown:renderHtml. It will transform a string of markdown into HTML either through the body of the tag:

<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 through the "text" attribute:

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

The plugin also adds a method to string to transform it from markdown to html:

    assert "<p>rain in spain</p>\n" == "rain in spain".markdownToHtml()

Revisions

  • 0.1 - Initial version with markdown taglib
  • 0.2 - Addition of patch from @dani_latorre adding markdownToHtml() method to String and MarkdownService

Updated