Markdown rendering in Text component corrupts plain-text content in structured UI (buttons, labels, prices)
Description
When a MarkdownRenderer is injected via MarkdownContext, every Text component's content is parsed as Markdown — including short, plain-text labels inside buttons, price tags, phone numbers, and other structured UI elements. Characters that are valid Markdown syntax (+, -, *, #, >, `, _) get silently misinterpreted.
Reproduction
{
"component": "Row",
"children": [
{ "component": "Button", "child": { "component": "Text", "text": "-" } },
{ "component": "Text", "text": "1" },
{ "component": "Button", "child": { "component": "Text", "text": "+" } }
]
}
{ "component": "Text", "text": "* tax included" }
But without markdown, variant won't render correctly either:
{ "component": "Text", "text": "Xi'an Famous Foods" }
Question
Currently, handleVariant() prepends Markdown syntax (e.g. # for h1) to the text content and relies on the injected MarkdownRenderer to produce the correct HTML. This creates a catch-22:
- With
MarkdownRendererinjected: variants render correctly, but plain-text characters like+,-,*,#are silently corrupted. - Without
MarkdownRenderer: plain text is safe, butvariant="h1"literally displays# Helloon screen becausehandleVariant()has already prepended the#prefix.
The variant implementation doesn't need to be coupled to the Markdown pipeline — CSS alone (font-size, font-weight, etc.) is sufficient to differentiate heading levels. Should the current variant-based approach be decoupled from Markdown rendering, rather than moving entirely to Markdown as proposed in #999?
Good point! What adapter are you using? A fix for the variant (to not use markdown rendering) landed in Angular a few days ago IIRC.
- See: https://github.com/google/A2UI/pull/1502