silverbullet/plugs/markdown/markdown.ts

17 lines
420 B
TypeScript
Raw Normal View History

2022-03-28 21:25:05 +08:00
import MarkdownIt from "markdown-it";
2022-04-01 23:07:08 +08:00
import { getText, showRhs } from "plugos-silverbullet-syscall/editor";
2022-03-28 21:25:05 +08:00
var taskLists = require("markdown-it-task-lists");
const md = new MarkdownIt({
linkify: true,
html: false,
typographer: true,
}).use(taskLists);
export async function renderMarkdown() {
2022-04-01 23:07:08 +08:00
let text = await getText();
2022-03-28 21:25:05 +08:00
let html = md.render(text);
2022-04-01 23:07:08 +08:00
await showRhs(`<html><body>${html}</body></html>`);
2022-03-28 21:25:05 +08:00
}