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](https://west-wind.com)."
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](https://west-wind.com)."

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

Remarks

Distribution dependencies:

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

Class Members

MemberDescription

Markdown (global function)

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

Parse

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)

lEncodeScriptBlocks

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.

lSanitizeHtml

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

Requirements

Assembly: markdownparser.prg

See also:

Class MarkdownParser | Class MarkdownParserExtended

© West Wind Technologies, 1996-2018 • Updated: 10/20/18
Comment or report problem with topic