silverbullet/plug-api/syscalls/markdown.ts

21 lines
626 B
TypeScript
Raw Permalink Normal View History

import { syscall } from "../syscall.ts";
2024-02-29 22:23:05 +08:00
import type { ParseTree } from "../lib/tree.ts";
2024-08-07 19:27:25 +08:00
/**
* Parses a piece of markdown text into a ParseTree.
* @param text the markdown text to parse
* @returns a ParseTree representation of the markdown text
*/
export function parseMarkdown(text: string): Promise<ParseTree> {
return syscall("markdown.parseMarkdown", text);
}
2024-08-15 17:45:46 +08:00
/**
* Renders a ParseTree to markdown.
* @param tree the parse tree
* @returns the rendered markdown of a passed parse tree
*/
export function renderParseTree(tree: ParseTree): Promise<string> {
return syscall("markdown.renderParseTree", tree);
}