Skip to content

Markdown: escaped brackets in link labels are rendered as display math #5310

Description

@sunrioa

What happened

A Markdown link label containing escaped brackets is interpreted as display math. The link remains present, but part of its label becomes a block-level KaTeX formula instead of ordinary text.

The original affected link was:

[\[DISCUSS\] Clarify Maka sandbox contracts and runtime dependency access](https://github.com/apache/maka/discussions/5304)

Expected: a single inline link with the visible label:

[DISCUSS] Clarify Maka sandbox contracts and runtime dependency access

Actual: DISCUSS is rendered as mathematical italic letters inside a display-math element within the link. In the attached Desktop screenshot, it appears centered separately from the remaining title, disrupting the surrounding inline layout.

Maka intentionally supports \[...\] as display-math syntax. This report concerns its interaction with Markdown link labels, where the same characters can represent literal escaped brackets.

How to reproduce

Render this source through Maka’s MarkdownBody:

最新一条是 **#5304**[\[DISCUSS\] Clarify Maka sandbox contracts and runtime dependency access](https://github.com/apache/maka/discussions/5304),作者 [zhiiw](https://github.com/zhiiw)

The following component-level reproduction uses imports relative to packages/ui/src:

import {createElement} from 'react';
import {renderToStaticMarkup} from 'react-dom/server';
import {LocaleProvider} from './locale-context.js';
import {MarkdownBody} from './markdown-body.js';

const text =
  '[\\[DISCUSS\\] Clarify](https://example.com)';

const markup = renderToStaticMarkup(
  createElement(
    LocaleProvider,
    {locale: 'zh-CN'},
    createElement(MarkdownBody, {text}),
  ),
);

console.log(markup);

The generated HTML contains this structure, with unrelated attributes omitted:

<a href="https://example.com">
  <span>
    <span class="maka-math maka-math-display">
      <span class="katex-display">
        <!-- DISCUSS rendered as mathematical letters -->
      </span>
    </span>
    Clarify
  </span>
</a>

The formula and remaining title are inside the same anchor; the result is not two separate links.

Environment

  • Surface: Desktop Markdown rendering
  • Local component reproduction: Maka commit a9b4f21afb17e0ef310d076382e69ddda3a441d7
  • Local dependency: @astryxdesign/core@0.5.2
  • macOS
  • Node.js v24.19.0

The local packages/ui/src/markdown-math.tsx was compared with main at c22768c3b0dc47518f6f8584e864f86f0b1e5379; their SHA-256 hashes match.

The exact build used for the original Desktop screenshot has not been independently verified. The component reproduction was performed separately.

Logs, screenshots, or additional context

Source observation

MarkdownBody applies prepareMarkdownMath() through Astryx’s transformSource before Markdown parsing.

The preprocessor recognizes \[DISCUSS\] as display math and replaces it with a transport token. Astryx then parses the outer link successfully. Maka’s math plugin renders the token with KaTeX using displayMode: true, inside the link label.

Relevant source:

Existing tests cover standalone display math. This report is specifically about its interpretation inside an inline link label.

Verification scope

The preprocessing result and generated component HTML were reproduced locally. The attached screenshot shows the observed Desktop rendering. The full Desktop layout was not reproduced pixel-for-pixel.

Screenshot

DISCUSS rendered as display math inside a link label in Maka

AI assistance: OpenAI Codex assisted with source inspection, component-level reproduction, and drafting this issue. I reviewed and approved the final report before submission.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions