1. Vitaliy Berdinskikh
  2. Markdown Taglib

Overview

HTTPS SSH

Markdown Taglib

The 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

codecov.io

Deprecation note

As the upstream project pegdown was deprecated all my related projects deprecated too.

Usage

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

License

Add Maven dependency

<dependency>
    <groupId>ua.co.ur6lad</groupId>
    <artifactId>markdown-taglib</artifactId>
    <version>1.1.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.6.0 or better;
  • slf4j: slf4j-api v1.7.7 or better;
  • any slf4j provider if you need logging.

Declare in JSP

<%@ taglib uri='http://ur6lad.co.ua/markdown-taglib' prefix ='md' %>

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, AtxHeaderSpace, ExtraAnchorinks, ForceListItemParagraph, RelaxedHorizontalRules, TaskListItems;
  • Anchorlinks: enables anchor links in headers;
  • AtxHeaderSpace: requires a space char after Atx # header prefixes;
  • Autolinks: enables plain autolinks the way github flavoured markdown implements them;
  • DefinitionLists: PHP Markdown Extra style definition lists;
  • ExtraAnchorinks: generate anchor links for headers using complete contents of the header;
  • FencedCodeBlocks: PHP Markdown Extra style fenced code blocks;
  • ForceListItemParagraph: force List and Definition Paragraph wrapping if it includes more than just a single paragraph;
  • 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;
  • RelaxedHorizontalRules: allow horizontal rules without a blank line following them;
  • 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;
  • TaskListItems: GitHub style task list items: - [ ] and - [x];
  • Wikilinks: support [[Wiki-style links]].

See more details on Options class page.

Demo application

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

Download

API Specification

Markdown Taglib 1.1.0 API

Crafted with jEdit