This commit is contained in:
Zef Hemel
2022-12-22 16:20:05 +01:00
parent fbb45f0525
commit cca48f66cd
10 changed files with 306 additions and 34 deletions
+5 -1
View File
@@ -30,4 +30,8 @@ functions:
sharePublisher:
path: ./share.ts:sharePublisher
events:
- share:file
- share:file
markdownWidget:
path: ./widget.ts:markdownWidget
codeWidget: markdown
+19
View File
@@ -0,0 +1,19 @@
import { parseMarkdown } from "$sb/silverbullet-syscall/markdown.ts";
import { renderMarkdownToHtml } from "./markdown_render.ts";
export async function markdownWidget(
bodyText: string,
): Promise<{ html: string; script: string }> {
const mdTree = await parseMarkdown(bodyText);
const html = renderMarkdownToHtml(mdTree, {
smartHardBreak: true,
});
return Promise.resolve({
html: html,
script: `updateHeight();
document.addEventListener("click", () => {
api({type: "blur"});
});`,
});
}