diff --git a/plug-api/syscalls/markdown.ts b/plug-api/syscalls/markdown.ts index 90ff29e3..be8766f0 100644 --- a/plug-api/syscalls/markdown.ts +++ b/plug-api/syscalls/markdown.ts @@ -19,6 +19,11 @@ export function renderParseTree(tree: ParseTree): Promise { return syscall("markdown.renderParseTree", tree); } +/** + * Expands custom markdown Lua directives and transclusions into plain markdown + * @param tree the parse tree + * @returns the expaneded markdown + */ export function expandMarkdown(tree: ParseTree): Promise { return syscall("markdown.expandMarkdown", tree); } diff --git a/website/API/markdown.md b/website/API/markdown.md index a05e8f69..0998f65d 100644 --- a/website/API/markdown.md +++ b/website/API/markdown.md @@ -29,3 +29,26 @@ local tree = markdown.parseMarkdown(text) -- Modify tree if needed local rendered = markdown.renderParseTree(tree) print("Rendered markdown:", rendered) +``` + +### markdown.markdownToHtml(text) +Renders a piece of markdown text into HTML + +Example: +```lua +local text = "# Title\n\nSome text" +local html = markdown.markdownToHtml(text) +print("Rendered html:", html) +``` + +### markdown.expandMarkdown(tree) +Expands custom markdown Lua directives and transclusions into plain markdown inside a ParseTree + +Example: +```lua +local text = "This is a some lua ${os.time()}" +local tree = markdown.parseMarkdown(text) +local expandedTree = markdown.expandMarkdown(tree) +local rendered = markdown.renderParseTree(expandedTree) +print("Rendered markdown:", rendered) +``` \ No newline at end of file