Overview

Introduction

Markdown Taglib is a JSP tag library used to render Markdown text to HTML. It uses pegdown.
Pegdown is a pure Java library for clean and lightweight Markdown processing.

Build Status

Add to your project

markdown-taglib is licensed under the Apache License v2.0

License

Add Maven dependency

Add markdown-taglib as a dependency to your pom.xml:

<dependency>
    <groupId>ua.co.ur6lad</groupId>
    <artifactId>markdown-taglib</artifactId>
    <version>1.0.0</version>
</dependency>

Maven Central

Manual installation

Download the jar of latest version from the download page on Bintray. Download the jar of markdown-options too from the download page on Bintray.

Download

Other Markdown Taglib dependencies:

  • asm: asm, asm-analysis, asm-tree and asm-util - v5.0.3 or better;
  • parboiled: parboiled-core and parboiled-java - v1.1.7 or better;
  • pegdown: v1.5.0 or better;
  • slf4j: slf4j-api v1.7.10 or better;
  • any slf4j provider if you need logging.

Using the Markdown Taglib

Render tag with text attribute:

<md:render text="Markdown _is_ __cool__!"/>

Another render tag with text and options attributes:

<md:render options="quotes" text="Markdown _is_ __cool__!"/>

Render tag with JSP body:

<md:render>
Markdown _is_ __cool__!
</md:render>

Using the config tag:

<md:config options="smarts">
    <md:render text="Markdown _is_ __cool__!"/>
    <md:render options="smarts">
        Use parent options...
    <md:render>
    <md:render options="quotes">
        Use with additional options...
        Cute <<quotes>>
    <md:render>
    <md:render options="none" overwriteConfigOptions="true">
        Overwrite config's options...
    <md:render>
</md:config>

Supported options

Use these names (any case):

  • Abbreviations: PHP Markdown Extra style abbreviations;
  • All: all available options except HTML ones;
  • Anchorlinks: enables anchor links in headers;
  • Autolinks: enables plain autolinks the way github flavoured markdown implements them;
  • DefinitionLists: PHP Markdown Extra style definition lists;
  • FencedCodeBlocks: PHP Markdown Extra style fenced code blocks;
  • Hardwraps: enables the parsing of hard wraps as HTML linebreaks;
  • None: the default, standard markup mode without any extensions, overwrites other options if uses;
  • Quotes: pretty single and double quotes;
  • Smarts: pretty ellipses, dashes and apostrophes;
  • Smartypants: smarts + quotes;
  • Strikethrough: support ~~strikethroughs~~ as supported in Pandoc and Github;
  • SuppressAllHtml: suppresses HTML blocks as well as inline HTML tags;
  • SuppressHtmlBlocks: suppresses HTML blocks;
  • SuppressInlineHtml: suppresses inline HTML tags.
  • Tables: table support similar to what Multimarkdown offers.
  • Wikilinks: support [[Wiki-style links]].

See more details on Options class page.

Demo application

Feel free to checkout or download the demo web-application.