silverbullet/common/syscalls/markdown.ts

17 lines
566 B
TypeScript
Raw Normal View History

2022-04-04 00:12:16 +08:00
import {SysCallMapping} from "../../plugos/system";
import {MarkdownTree, nodeAtPos, parse, render} from "../tree";
export function markdownSyscalls(): SysCallMapping {
return {
"markdown.parse": (ctx, text: string): MarkdownTree => {
2022-04-04 00:12:16 +08:00
return parse(text);
},
"markdown.nodeAtPos": (ctx, mdTree: MarkdownTree, pos: number): MarkdownTree | null => {
2022-04-04 00:12:16 +08:00
return nodeAtPos(mdTree, pos);
},
"markdown.render": (ctx, mdTree: MarkdownTree): string => {
2022-04-04 00:12:16 +08:00
return render(mdTree);
},
};
}