A2UI icon indicating copy to clipboard operation
A2UI copied to clipboard

Markdown rendering in Text component corrupts plain-text content in structured UI (buttons, labels, prices)

Open chenman9226 opened this issue 6 months ago • 1 comments

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": "+" } }
  ]
}
Image
{ "component": "Text", "text": "* tax included" }
Image

But without markdown, variant won't render correctly either:

{ "component": "Text", "text": "Xi'an Famous Foods" }
Image

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 MarkdownRenderer injected: variants render correctly, but plain-text characters like +, -, *, # are silently corrupted.
  • Without MarkdownRenderer: plain text is safe, but variant="h1" literally displays # Hello on screen because handleVariant() 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?

chenman9226 avatar Jun 02 '26 09:06 chenman9226

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

ditman avatar Jun 02 '26 20:06 ditman