Markdown Viewtool

Last Updated: Jun 22, 2021
documentation for the dotCMS Content Management System

This dotCMS viewtool provides a github flavored markdown (gfm) compatible markdown parser (for the most part). It is built off of the txtmark project by René Jeschke. It provides a viewtool that can be used in dotCMS to parse text/content for gfm.


The Markdown viewtool supports the following two methods:

$markdown.parse()Parses a Markdown formatted string.
$markdown.parseFile()Parses a file containing Markdown formatted text (which may be mixed with Velocity code).

Parse a Markdown-Formatted String




formatted-stringRequiredA Markdown formatted string (using Github markdown format).


The following call to the viewtool when iterating over content in velocity:

$markdown.parse(">**Parse** *this* ~~string~~")

produces the following result:

Parse this string

Parse a Field in a Velocity Pull

In a Velocity pull of content, you can use the $markdown.parse tool to iterate over a text field that has both Velocity and Markdown. The Velocity will execute by default, as long as you are looking at your backend page in Live Mode.


#foreach($con in $dotcontent.pull("+contentType:webPageContent)",10,"modDate desc"))
    $markdown.parse($content.getRaw("$con.body"))  ## body field Velocity executes, gets the raw field string AND displays text in Markdown format

Parse a File in Markdown Format

You can parse a file that contains Markdown-formatted text using the $markdown.parseFile() method. The parseFile() method supports both pain Markdown files and files which combine both Markdown and Velocity code.


$markdown.parseFile(file_name, parse_velocity)


file_nameRequiredThe URL of the file to be parsed (on the local dotCMS Site).
parse_velocityfalseA boolean flag specifying whether the contents should be parsed for Velocity as well as Markdown.


Files Containing Markdown Only

If a file contains only Markdown text (and no Velocity code), you can parse the file using either of the following calling conventions:

$markdown.parseFile("/application/", false)

Combined Markdown and Velocity

To parse a file that contains both Velocity and Markdown, you must supply a value of true to the parse_velocity parameter:

$markdown.parseFile("/application/", true)

Files on a Different Host

To parse a file on a different site (hosted in the same dotCMS instance), include the site name specification when referencing the file:


This parses the file /application/ on the site

Toolbox.xml Configuration

The following example shows how the Markdown Viewtool is mapped in the toolbox.xml file:


On this page


We Dig Feedback

Selected excerpt: