markdownToHTML: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page MarkdownToHTML to markdownToHTML: Converting page titles to lowercase)
No edit summary
Line 7: Line 7:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
markdownToHTML(string)
markdownToHTML(string)
markdownToHTML(string, type)
markdownToHTML(string, type)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|string|The markdown text to be converted.}}
{{param|string|The markdown text to be converted.}}
Line 38: Line 38:
Retrieve the text stored in the current token's '''Notes''' and convert them to HTML for display inside a {{func|frame5}}.
Retrieve the text stored in the current token's '''Notes''' and convert them to HTML for display inside a {{func|frame5}}.


<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[frame5("Notes", "title=" + token.name): {<br>
[frame5("Notes", "title=" + token.name): {<br>
[r: markdownToHTML(getNotes())]
[r: markdownToHTML(getNotes())]
}]
}]
</source>
</syntaxhighlight>


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


<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: html = startsWith(getNotes(), "<")]
[h: html = startsWith(getNotes(), "<")]
[h, if(html==1):
[h, if(html==1):
Line 54: Line 54:
     [r: content]
     [r: content]
}]
}]
</source>
</syntaxhighlight>


}}
}}
[[Category:Miscellaneous Function]]
[[Category:Miscellaneous Function]]

Revision as of 17:53, 15 March 2023

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]
}]