fix(markdown): preserve descriptive file-link labels #10794
Closed
Gigioxx(GitHub profile, opens in a new tab)wants to merge 5 commits into
main fromrefs/pull/10794/head·opened View on GitHubShowing 7 changed files with 52 additions and 15 deletions (loading 4).
x
7 additions and 2 deletions+7-2apps/mobile/modules/t3-markdown-text/src/nativeMarkdownText.tsModifiedView file
@@ -1,3 +1,4 @@
+import { isMarkdownFileLinkLabel } from "@t3tools/client-runtime/markdown-links";
@@ -423,7 +424,7 @@
-function nodeTextContent(node: MarkdownNode): string {
+export function nodeTextContent(node: MarkdownNode): string {
@@ -480,7 +481,11 @@
- return appendRun(runs, presentation.label, {
+ const descriptive = !isMarkdownFileLinkLabel(nodeTextContent(node), presentation.href);
+ if (descriptive) {
+ appendChildren(runs, node, { ...context, href: presentation.href });
+ }
+ return appendRun(runs, descriptive ? ` (${presentation.label})` : presentation.label, {
Thread on line 488
🟡 Medium src/nativeMarkdownText.ts:488
On Android, copying a descriptive file link drops its prose label from the canonical Markdown link, producing text such as validates the input [(example.ts)](<...>) instead of a link labeled validates the input. appendChildren emits the label as an ordinary href run, while line 488 emits only the filename suffix as the fileIcon run that nativeMarkdownContextCopyRanges canonicalizes. Keep the descriptive label and filename in the same canonicalized file-link run, or update the copy-range logic to include the preceding label run.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/mobile/modules/t3-markdown-text/src/nativeMarkdownText.ts around line 488:
On Android, copying a descriptive file link drops its prose label from the canonical Markdown link, producing text such as `validates the input [(example.ts)](<...>)` instead of a link labeled `validates the input`. `appendChildren` emits the label as an ordinary `href` run, while line 488 emits only the filename suffix as the `fileIcon` run that `nativeMarkdownContextCopyRanges` canonicalizes. Keep the descriptive label and filename in the same canonicalized file-link run, or update the copy-range logic to include the preceding label run.