Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(markdown): preserve descriptive file-link labels #10794

ClosedGigioxx(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/10794/headopened View on GitHub

Showing 7 changed files with 52 additions and 15 deletions (loading 4).

x
0 of 7 viewed, 7 left
7 additions and 2 deletionsapps/mobile/modules/t3-markdown-text/src/nativeMarkdownText.tsModified
View file
@@ -1,3 +1,4 @@
+import { isMarkdownFileLinkLabel } from "@t3tools/client-runtime/markdown-links";
import type { MarkdownNode } from "react-native-nitro-markdown/headless";
import { collectComposerInlineTokens } from "@t3tools/shared/composerInlineTokens";
import { imageMimeType } from "@t3tools/shared/image";
@@ -423,7 +424,7 @@
return runs;
​
-function nodeTextContent(node: MarkdownNode): string {
+export function nodeTextContent(node: MarkdownNode): string {
if (node.content !== undefined) {
return node.content;
@@ -480,7 +481,11 @@
const presentation = resolveMarkdownLinkPresentation(node.href ?? "");
if (presentation.kind === "file") {
- 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
macroscopeapp[bot](GitHub profile, opens in a new tab)commented

🟡 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.
...context,
href: presentation.href,
fileIcon: presentation.icon,