2024-02-09 04:00:45 +08:00
|
|
|
import { syscall } from "../syscall.ts";
|
2024-02-29 22:23:05 +08:00
|
|
|
import type { ParseTree } from "../lib/tree.ts";
|
2022-10-10 20:50:21 +08:00
|
|
|
|
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
|
|
|
|
*/
|
2022-10-10 20:50:21 +08:00
|
|
|
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);
|
|
|
|
}
|