Agile Ajax

Markdown support for GWT in 42 seconds

As promised earlier, here is Markdown support in GWT.

1) Grab Showdown
2) Copy 'showdown.js' to the 'public' directory of your application.
3) Edit your module file:

    <module>        <!-- .... -->        <script src="showdown.js"/>        <!-- .... -->    </module>

4) Use JSNI to invoke Showdown.

    public static native String convert(String text) /*-{        var converter = new $wnd.Showdown.converter();        return converter.makeHtml(text);    }-*/;

5) Invoke 'convert()' as needed.  In my case, I wired it up to a KeyboardListener attached to a TextArea, and had the results placed on an HTML object.

And yes, it's that simple.

Topics:

Leave a comment

Powered by WP Hashcash

About Pathfinder

  • We design and build extraordinary applications for companies looking to make the next great idea a reality.
  • learn more

Topics

WordPress

Comments about this site: info@pathf.com