2024-07-30 23:33:33 +08:00
|
|
|
import type { SysCallMapping } from "../../lib/plugos/system.ts";
|
2023-10-03 20:16:33 +08:00
|
|
|
import { parse } from "../markdown_parser/parse_tree.ts";
|
2024-08-15 17:45:46 +08:00
|
|
|
import { type ParseTree, renderToText } from "../../plug-api/lib/tree.ts";
|
2024-01-24 20:34:12 +08:00
|
|
|
import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
|
2022-10-10 20:50:21 +08:00
|
|
|
|
2024-01-24 20:34:12 +08:00
|
|
|
export function markdownSyscalls(): SysCallMapping {
|
2022-10-10 20:50:21 +08:00
|
|
|
return {
|
|
|
|
"markdown.parseMarkdown": (_ctx, text: string): ParseTree => {
|
2024-01-24 20:34:12 +08:00
|
|
|
return parse(extendedMarkdownLanguage, text);
|
2022-10-10 20:50:21 +08:00
|
|
|
},
|
2024-08-15 17:45:46 +08:00
|
|
|
"markdown.renderParseTree": (_ctx, tree: ParseTree): string => {
|
|
|
|
return renderToText(tree);
|
|
|
|
},
|
2022-10-10 20:50:21 +08:00
|
|
|
};
|
|
|
|
}
|