Skip to content

[Bug]: Mobile markdown fails to autolink bare URLs adjacent to CJK characters or full-width punctuation #46414

Done

Description

@imetn

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/mobile

Steps to reproduce

  1. Open any thread in the T3 Code mobile app (iOS / Android).
  2. Send or receive a markdown message containing a bare http:// or https:// URL immediately adjacent to CJK characters or full-width punctuation (with no ASCII space), for example:
    • 参考链接:https://github.com/pingdotgg/t3code
    • (https://github.com/pingdotgg/t3code)
    • 详见 https://github.com/pingdotgg/t3code,这里有说明
  3. Observe how the URL renders in EnrichedMarkdownText and try tapping it.

Expected behavior

The bare URL (https://github.com/pingdotgg/t3code) should be recognized as a tappable hyperlink while keeping the surrounding CJK characters and full-width punctuation (: / ( / ) / ,) outside the link — matching the web behavior fixed in #35138.

Actual behavior

On mobile, bare URLs adjacent to CJK text or full-width punctuation either render as plain untappable text (when preceded by CJK text or full-width punctuation such as : / () or swallow trailing full-width text/punctuation into the link.

Root cause:

  • [Bug]: Bare URLs followed by CJK text or full-width punctuation link the rest of the sentence (and swallow **bold**) #35138 fixed this for the web pipeline in packages/shared/src/markdownPipeline.ts (remarkEndAutolinksAtScriptPunctuation).
  • Mobile renders assistant markdown through react-native-enriched-markdown (md4c) via apps/mobile/src/native/EnrichedMarkdownText.tsx (L276) and apps/mobile/src/lib/markdownDocument.ts (markdownForNativeRendering), which does not go through markdownPipeline.ts.
  • md4c's GFM permissive autolink scanner only treats ASCII whitespace and ASCII delimiter characters ((, {, [, etc.) as valid leading boundaries for bare URLs, so CJK characters and full-width punctuation prevent md4c from recognizing the bare URL at all.

Wrapping bare http(s):// URLs outside code/math/existing links in CommonMark angle-bracket autolinks (<https://...>) during the AST transform in apps/mobile/src/lib/markdownDocument.ts lets md4c parse them reliably regardless of surrounding CJK text or full-width punctuation.

Impact

Minor bug or occasional failure

Version or commit

main @ e4134b7

Environment

iOS / React Native mobile app (apps/mobile, react-native-enriched-markdown / md4c)

Logs or stack traces

Input markdown:
  参考链接:https://github.com/pingdotgg/t3code
  (https://github.com/pingdotgg/t3code)

Rendered in mobile EnrichedMarkdownText (md4c):
  Plain untappable text instead of an autolinked https://github.com/pingdotgg/t3code

Workaround

Add ASCII spaces around every bare URL or write explicit [label](url) / <url> markdown syntax.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions