Skip to content

Commit 5e79829

Browse files
committed
fix(gallery): provide MarkdownRenderer to A2UI Lit surface
Basic catalog Text component prepends "## " etc. for variant headings (h1..h5) and pipes the result through Context.markdown. Without a provider the markdown leaks as literal text like "## Recent activity". Wire @a2ui/markdown-it on document via the context-request event protocol so every <a2ui-surface> in the gallery sees it.
1 parent ec7e0f6 commit 5e79829

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

gallery/build.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,20 @@ const html = `<!DOCTYPE html>
623623
async function loadA2UI() {
624624
if (a2uiInit) return a2uiInit;
625625
a2uiInit = (async () => {
626-
const [core, lit] = await Promise.all([
626+
const [core, lit, md] = await Promise.all([
627627
import('https://esm.sh/@a2ui/web_core@0.9.2/v0_9'),
628628
import('https://esm.sh/@a2ui/lit@0.9.3/v0_9'),
629+
import('https://esm.sh/@a2ui/markdown-it@0.0.4'),
629630
]);
631+
// Provide a MarkdownRenderer via Lit context. Without it, the basic
632+
// catalog Text component prepends "## " etc. for variant headings
633+
// and (with no renderer) shows them as literal text.
634+
document.addEventListener('context-request', (e) => {
635+
if (e.context === lit.Context.markdown) {
636+
e.stopPropagation();
637+
e.callback(md.renderMarkdown);
638+
}
639+
}, { capture: false });
630640
return { MessageProcessor: core.MessageProcessor, basicCatalog: lit.basicCatalog };
631641
})();
632642
return a2uiInit;

gallery/index.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3299,10 +3299,20 @@ <h2 class="section-h">Canonical types</h2>
32993299
async function loadA2UI() {
33003300
if (a2uiInit) return a2uiInit;
33013301
a2uiInit = (async () => {
3302-
const [core, lit] = await Promise.all([
3302+
const [core, lit, md] = await Promise.all([
33033303
import('https://esm.sh/@a2ui/web_core@0.9.2/v0_9'),
33043304
import('https://esm.sh/@a2ui/lit@0.9.3/v0_9'),
3305+
import('https://esm.sh/@a2ui/markdown-it@0.0.4'),
33053306
]);
3307+
// Provide a MarkdownRenderer via Lit context. Without it, the basic
3308+
// catalog Text component prepends "## " etc. for variant headings
3309+
// and (with no renderer) shows them as literal text.
3310+
document.addEventListener('context-request', (e) => {
3311+
if (e.context === lit.Context.markdown) {
3312+
e.stopPropagation();
3313+
e.callback(md.renderMarkdown);
3314+
}
3315+
}, { capture: false });
33063316
return { MessageProcessor: core.MessageProcessor, basicCatalog: lit.basicCatalog };
33073317
})();
33083318
return a2uiInit;

0 commit comments

Comments
 (0)