Signature
String markdown_to_html(String src) String markdown_to_html(String src, DValue options)
Parameters
Renders Markdown source into HTML and returns the generated markup as a String.
markdown_to_html() does not write to the output stream directly. This keeps it aligned with the UCE naming convention where render_* names are reserved for direct-output helpers.
Because the return value is HTML markup, embed it with <?: markdown_to_html(...) ?>, print(markdown_to_html(...)), or pass it through a component.
By default the function aims at a practical GitHub-flavored Markdown target, including tables, task lists, fenced code blocks, autolinks, and strikethrough.
Example:
Supported syntax:
headings with
#or setext underlinesparagraphs
ordered and unordered lists
task lists
blockquotes
fenced code blocks
horizontal rules
tables
inline emphasis, strong, strikethrough, and code spans
links, images, and bare
http:///https://URLs:::name ... :::directive blocks
Options:
options["gfm"]defaults totrueand turns on GitHub-style extras such as tables, task lists, autolinks, and strikethrough.options["allow_html"]defaults tofalse. When true, raw HTML blocks and inline tags may pass through asraw_htmlnodes instead of being escaped as plain text.options["components"]declares renderer extension points using normal UCE components.
Directive hook example:
Generic node hook examples:
If both an exact directive hook and a generic node.directive hook exist, the exact directive hook wins.
When a markdown hook component is called, its props arrive in context.props.
Useful fields include:
context.props["hook"]for the matched hook key such as:::warningornode.code_blockcontext.props["target"]for the resolved component target namecontext.props["default_html"]for the renderer output without the hookcontext.props["children_html"]for already-rendered child HTMLcontext.props["node"]for the full AST nodecontext.props["type"]for the node typecontext.props["name"]for the directive name when applicablecontext.props["argument"]for directive remainder after the namecontext.props["text"]for source text used by nodes such ascode_blockcontext.props["lang"]for fenced code languagecontext.props["href"],context.props["src"], andcontext.props["title"]context.props["options"]for the full markdown options tree
Directive blocks use this form:
The parser stores:
That makes directive components a good fit for alerts, callouts, cards, embeds, and richer page-level Markdown extensions.
Example
print(markdown_to_html("**bold**"), "\n");
<p><strong>bold</strong></p>