import { editor, space, system } from "$sb/silverbullet-syscall/mod.ts"; import { asset, store } from "$sb/plugos-syscall/mod.ts"; import { parseMarkdown } from "$sb/silverbullet-syscall/markdown.ts"; import { renderMarkdownToHtml } from "./markdown_render.ts"; export async function updateMarkdownPreview() { if (!(await store.get("enableMarkdownPreview"))) { return; } const text = await editor.getText(); const mdTree = await parseMarkdown(text); // const cleanMd = await cleanMarkdown(text); const css = await asset.readAsset("assets/styles.css"); const js = await asset.readAsset("assets/handler.js"); const html = renderMarkdownToHtml(mdTree, { smartHardBreak: true, annotationPositions: true, inlineAttachments: (url) => { if (!url.includes("://")) { return `/.fs/${url}`; } return url; }, }); await editor.showPanel( "rhs", 2, `