diff --git a/plug-api/lib/markdown.ts b/plug-api/lib/markdown.ts index ba2a96c5..7cb52cef 100644 --- a/plug-api/lib/markdown.ts +++ b/plug-api/lib/markdown.ts @@ -103,7 +103,6 @@ export function stripMarkdown( return tree.children![0].text!; } - case "TemplateDirective": case "DeadlineDate": { return renderToText(tree); } diff --git a/plugs/markdown/markdown_render.ts b/plugs/markdown/markdown_render.ts index 668956f0..98020440 100644 --- a/plugs/markdown/markdown_render.ts +++ b/plugs/markdown/markdown_render.ts @@ -472,15 +472,6 @@ function render( case "Entity": return t.children![0].text!; - case "TemplateDirective": { - return { - name: "span", - attrs: { - class: "template-directive", - }, - body: renderToText(t), - }; - } case "Superscript": return { name: "sup", diff --git a/plugs/markdown/preview.ts b/plugs/markdown/preview.ts index 0b42cc76..0e557c89 100644 --- a/plugs/markdown/preview.ts +++ b/plugs/markdown/preview.ts @@ -18,7 +18,6 @@ export async function updateMarkdownPreview() { const currentPage = await editor.getCurrentPage(); const text = await editor.getText(); let mdTree = await markdown.parseMarkdown(text); - // const cleanMd = await cleanMarkdown(text); const css = await asset.readAsset("markdown", "assets/preview.css"); const js = await asset.readAsset("markdown", "assets/preview.js"); @@ -68,14 +67,10 @@ function renderToolbar(): string { export async function previewClickHandler(e: any) { const [eventName, arg] = JSON.parse(e); - // console.log("Got click", eventName, arg); switch (eventName) { case "pos": // console.log("Moving cursor to", +arg); await editor.moveCursor(+arg, true); break; - case "command": - await system.invokeCommand(arg); - break; } } diff --git a/web/cm_plugins/lua_widget.ts b/web/cm_plugins/lua_widget.ts index b7714ca1..370d5eef 100644 --- a/web/cm_plugins/lua_widget.ts +++ b/web/cm_plugins/lua_widget.ts @@ -163,9 +163,6 @@ export class LuaWidget extends WidgetType { ); html = parseHtmlString(renderMarkdownToHtml(mdTree, { - // Annotate every element with its position so we can use it to put - // the cursor there when the user clicks on the table. - annotationPositions: true, translateUrls: (url) => { if (isLocalPath(url)) { url = resolvePath( diff --git a/web/cm_plugins/smart_quotes.ts b/web/cm_plugins/smart_quotes.ts index 2bf56816..af7a9043 100644 --- a/web/cm_plugins/smart_quotes.ts +++ b/web/cm_plugins/smart_quotes.ts @@ -13,7 +13,6 @@ const straightQuoteContexts = [ "FrontMatterCode", "Attribute", "CommandLink", - "TemplateDirective", "LuaDirective", ]; diff --git a/web/cm_plugins/table.ts b/web/cm_plugins/table.ts index bea29684..ec837916 100644 --- a/web/cm_plugins/table.ts +++ b/web/cm_plugins/table.ts @@ -15,6 +15,8 @@ import { isLocalPath, resolvePath, } from "@silverbulletmd/silverbullet/lib/resolve"; +import { expandMarkdown } from "../markdown.ts"; +import { LuaStackFrame } from "../space_lua/runtime.ts"; class TableViewWidget extends WidgetType { tableBodyText: string; @@ -41,25 +43,35 @@ class TableViewWidget extends WidgetType { }); }); - dom.innerHTML = renderMarkdownToHtml(this.t, { - // Annotate every element with its position so we can use it to put - // the cursor there when the user clicks on the table. - annotationPositions: true, - translateUrls: (url) => { - if (isLocalPath(url)) { - url = resolvePath(this.client.currentPage, decodeURI(url)); - } + const sf = LuaStackFrame.createWithGlobalEnv( + client.clientSystem.spaceLuaEnv.env, + ); + expandMarkdown( + client, + this.t, + client.clientSystem.spaceLuaEnv.env, + sf, + ).then((t) => { + dom.innerHTML = renderMarkdownToHtml(t, { + // Annotate every element with its position so we can use it to put + // the cursor there when the user clicks on the table. + annotationPositions: true, + translateUrls: (url) => { + if (isLocalPath(url)) { + url = resolvePath(this.client.currentPage, decodeURI(url)); + } - return url; - }, - preserveAttributes: true, - }); - - setTimeout(() => { - this.client.setCachedWidgetHeight( - `table:${this.tableBodyText}`, - dom.clientHeight, - ); + return url; + }, + preserveAttributes: true, + }); + setTimeout(() => { + // Give it a tick to render + this.client.setCachedWidgetHeight( + `table:${this.tableBodyText}`, + dom.clientHeight, + ); + }); }); return dom; }