markdownToHTML: Difference between revisions
m (Conversion script moved page markdownToHTML to MarkdownToHTML without leaving a redirect: Converting page title to first-letter uppercase) |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 7: | Line 7: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
markdownToHTML(string) | markdownToHTML(string) | ||
markdownToHTML(string, type) | markdownToHTML(string, type) | ||
</ | </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}}. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[frame5("Notes", "title=" + token.name): {<br> | [frame5("Notes", "title=" + token.name): {<br> | ||
[r: markdownToHTML(getNotes())] | [r: markdownToHTML(getNotes())] | ||
}] | }] | ||
</ | </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. | ||
< | <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] | ||
}] | }] | ||
</ | </syntaxhighlight> | ||
}} | }} | ||
[[Category:Miscellaneous Function]] | [[Category:Miscellaneous Function]] |
Latest revision as of 17:53, 15 March 2023
markdownToHTML() Function
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
[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]
}]