Class MarkdownParser

This class and the Markdown() helper function, provide Markdown parsing for converting Markdown text to HTML.

In it's simplest for you can do:

DO MarkdownParser && Load Library (once)
lcMarkdown = "This is **bold** text and this is [linked]("
lcHtml = Markdown(lcMarkdown)

The helper function is the preferred way to use the Markdown parser as it caches the Markdown parser rather than recreating the Markdown processing pipeline for each request.

Alternately you can explicitly use the MarkdownParser or MarkdownParserExtended classes, which give a little more control over various options:

lcMarkdown = "This is **bold** text and this is [linked]("

loParser = CREATEOBJECT("MarkdownParser")
loParser.lSanitizeHtml = .T.
llUtf8 = .T.  && encode markdown to UTF8 before sending to Parser


Distribution dependencies:

  • wwdotnetbridge.dll
  • wwipstuff.dll
  • markdig.dll

Class Members




Markdown (global function)

o.MarkdownParser.Markdown(lcMarkdown,lnMode, llReload,llUtf8, llNoSanitizeHtml, llNoHtmlAllowed)


Parses a Markdown text string to HTML using the CommonMark specification.

Markdown is parsed in basic format with no additional fixups.

o.Parse(lcMarkdownText, llUtf8)


If .T. handles <% %> script blocks in a special way by stripping them out of the document and then adding them back in after Markdown rendering. This preserves the original code and allows the script to stay embedded in the document as is.


If .T. doesn't process raw HTML inside of the Markdown. Instead the HTML is HTML Encoded and embedded into the documented as text.


If .T. sanitizes the HTML for XSS attacks by stripping script blocks, javascript: directives and removing onXXX events from elements.


Assembly: markdownparser.prg

See also:

Class MarkdownParser | Class MarkdownParserExtended

© West Wind Technologies, 1996-2022 • Updated: 03/24/19
Comment or report problem with topic