markdownToHTML

From RPTools Wiki
Jump to navigationJump to search

markdownToHTML() Function

Introduced in version 1.7.0
Converts the supplied markdown text string to HTML5.

Usage

markdownToHTML(string)
markdownToHTML(string, type)

Parameters

  • string - The markdown text to be converted.
  • type - The format of the markdown used as input.

The following types of Markdown are supported. Any of these profile names can be passed as strings for the type parameter.

  • COMMONMARK
  • COMMONMARK_0_26
  • COMMONMARK_0_27
  • COMMONMARK_0_28
  • COMMONMARK_0_29
  • FIXED_INDENT
  • GITHUB
  • GITHUB_DOC
  • KRAMDOWN
  • MARKDOWN
  • MULTI_MARKDOWN
  • PEGDOWN
  • PEGDOWN_STRICT

The details of which features are included in which profile seem to be difficult to find. However, the CommonMark standard that attempts to define what all Markdown profiles should include is available here. And a web search for the above keywords should produce links that provide a summary of the feature set for each profile.

The details of which features are actually supported are available on the software's Wiki page. But without a list identifying which extensions are part of which profile, it's not clear how a user should select a particular one.

Examples

Retrieve the text stored in the current token's Notes and convert them to HTML for display inside a frame5().
[frame5("Notes", "title=" + token.name): {<br>
[r: markdownToHTML(getNotes())]
}]

Same as the previous example, but check first to see if the Notes field already contains HTML.

[h: html = startsWith(getNotes(), "<")]
[h, if(html==1):
    content = getNotes();
    content = markdownToHTML(getNotes(), "GITHUB_DOC")]
[frame5("Notes", "title=" + token.name): {
    [r: content]
}]