Expose render parse tree (#1032)
parent
46f94a9881
commit
9b88a8d694
|
@ -1,6 +1,6 @@
|
|||
import type { SysCallMapping } from "../../lib/plugos/system.ts";
|
||||
import { parse } from "../markdown_parser/parse_tree.ts";
|
||||
import type { ParseTree } from "../../plug-api/lib/tree.ts";
|
||||
import { type ParseTree, renderToText } from "../../plug-api/lib/tree.ts";
|
||||
import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
|
||||
|
||||
export function markdownSyscalls(): SysCallMapping {
|
||||
|
@ -8,5 +8,8 @@ export function markdownSyscalls(): SysCallMapping {
|
|||
"markdown.parseMarkdown": (_ctx, text: string): ParseTree => {
|
||||
return parse(extendedMarkdownLanguage, text);
|
||||
},
|
||||
"markdown.renderParseTree": (_ctx, tree: ParseTree): string => {
|
||||
return renderToText(tree);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,3 +9,12 @@ import type { ParseTree } from "../lib/tree.ts";
|
|||
export function parseMarkdown(text: string): Promise<ParseTree> {
|
||||
return syscall("markdown.parseMarkdown", text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue