From 9676ca85635c480f85756fbb3ad25a7dbda3f550 Mon Sep 17 00:00:00 2001 From: Anthony Lawn Date: Tue, 21 Jul 2026 03:04:55 -0500 Subject: [PATCH] Fix transclusions of custom syntaxes not closing html tags (#2057) Co-authored-by: thepaperpilot --- client/codemirror/inline_content.ts | 42 +++++++++++++++++++---------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/client/codemirror/inline_content.ts b/client/codemirror/inline_content.ts index a51d5e68..1c61b8e0 100644 --- a/client/codemirror/inline_content.ts +++ b/client/codemirror/inline_content.ts @@ -15,17 +15,20 @@ import { expandMarkdown, readTransclusionContent, } from "../markdown_renderer/inline.ts"; +import { renderMarkdownToHtml } from "../markdown_renderer/markdown_render.ts"; import { isLocalURL, resolveMarkdownLink, } from "@silverbulletmd/silverbullet/lib/resolve"; -import { parseMarkdown } from "../markdown_parser/parser.ts"; +import { buildExtendedMarkdownLanguage } from "../markdown_parser/parser.ts"; +import { parse } from "../markdown_parser/parse_tree.ts"; import { renderToText } from "@silverbulletmd/silverbullet/lib/tree"; import { nameFromTransclusion, parseTransclusion, } from "@silverbulletmd/silverbullet/lib/transclusion"; import { parseToRef } from "@silverbulletmd/silverbullet/lib/ref"; +import { buildTranslateUrls } from "./widget_util.ts"; export function inlineContentPlugin(client: Client) { return decoratorStateField((state: EditorState) => { @@ -97,21 +100,32 @@ export function inlineContentPlugin(client: Client) { client.space, transclusion, ); + const syntaxExtensions = client.config.get( + "syntaxExtensions", + {}, + ); + const mdLang = + buildExtendedMarkdownLanguage(syntaxExtensions); + const expandedTree = await expandMarkdown( + client.space, + nameFromTransclusion(transclusion), + parse(mdLang, result.text, result.offset), + client.clientSystem.spaceLuaEnv, + { syntaxExtensions }, + ); content = { - markdown: renderToText( - await expandMarkdown( - client.space, - nameFromTransclusion(transclusion), - parseMarkdown(result.text, result.offset), - client.clientSystem.spaceLuaEnv, - { - syntaxExtensions: client.config.get( - "syntaxExtensions", - {}, - ), - }, - ), + html: renderMarkdownToHtml( + expandedTree, + { + shortWikiLinks: client.config.get( + "shortWikiLinks", + true, + ), + translateUrls: buildTranslateUrls(client), + }, + client.ui.viewState.allPages, ), + markdown: renderToText(expandedTree), }; } catch { const element = createMediaElement(transclusion);