The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): preserve line breaks in Markdown table cells (#29355)
Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: maria-rcks <maria@kuuro.net>
shivam committed
Nov 7, 2026 at 10:14 UTC
9f2bb98a8508ec9f6e695bf5d127aeadd06467f5
6 files changed
+116
-11
apps/mobile/deps/README.md
+2
@@ -1,3 +1,5 @@
1
The Enriched Markdown tarball comes from Julius's [`fork/t3-mobile` branch](https://github.com/pingdotgg/enriched-markdown/tree/fork/t3-mobile). Its `t3-fork.json` records the exact source commit and upstream base. React block renderers and signed image sources (`renderers`, `resolveImageSource`) are upstream. The fork carries native streaming memory bounds (an 8 MiB measurement-key budget and coalesced pending renders), plus changes with an open upstream PR: the `onLinksChange` link list that link pills and iOS link menus read ([#1088](https://github.com/software-mansion/enriched-markdown/pull/1088)), Android inline image alignment ([#1089](https://github.com/software-mansion/enriched-markdown/pull/1089)), clipboard link metadata ([#962](https://github.com/software-mansion/enriched-markdown/pull/962)), development-host autolinks ([#961](https://github.com/software-mansion/enriched-markdown/pull/961)), and `md4cFlags.preserveWindowsPaths`, which keeps backslashes in Windows drive paths in prose ([#1105](https://github.com/software-mansion/enriched-markdown/pull/1105), after [md4c#5](https://github.com/software-mansion-labs/md4c/pull/5)).
2
3
To replace it, commit the fork changes, run `yarn install --immutable` and `yarn workspace react-native-enriched-markdown prepare` in the fork checkout, then `node scripts/pack-t3.mjs /path/to/t3code/apps/mobile/deps`. Keep the package version aligned with Julius's `fork/t3-mobile` branch. Rename the archive to include the first eight characters of the source commit, such as `react-native-enriched-markdown-1.2.0-t3.16-8d2f84a8.tgz`, so each build has a distinct dependency path without version bumps. Update the tarball path in `apps/mobile/package.json` and `pnpm-workspace.yaml`'s `allowBuilds`, and run `vp i` to update the lockfile. Native clients need rebuilding when this dependency changes.
4
+
5
+`patches/react-native-enriched-markdown@1.2.0-t3.16.patch` writes a newline inside a copied table cell as `<br>`, so Copy as Markdown keeps the row whole. It is not in the fork yet; fold it into `fork/t3-mobile` or drop it when you replace the tarball, since pnpm applies it to any archive with the same version.
apps/mobile/src/lib/markdownDocument.ts
+2
-2
@@ -229,8 +229,8 @@ function htmlTagMarkdown(
229
const blockBreak = anchors.open === 0 ? "\n\n" : " ";
230
if (/^<summary\b/i.test(tag)) return `${blockBreak}**`;
231
if (/^<\/summary\s*>/i.test(tag)) return `**${blockBreak}`;
232
- // A line break would end the table row, so a cell keeps its content on one line.
233
- if (/^<br\b/i.test(tag)) return options.inTableCell ? " " : " \n";
232
+ // A raw newline would end the table row; both parsers decode this reference to one inside the cell.
233
+ if (/^<br\b/i.test(tag)) return options.inTableCell ? " " : " \n";
234
if (/^<\/?(?:p|div|details)\b/i.test(tag)) return blockBreak;
235
return "";
236
}
apps/mobile/src/lib/markdownHtml.test.ts
+15
-7
@@ -85,19 +85,27 @@ describe("HTML in native Markdown", () => {
85
expect(result).toContain('<img src="after.png">\n</details>');
86
});
87
88
- it("links HTML anchors in a table cell without breaking the row at <br>", () => {
89
- const document = parseMarkdownDocument(
90
- "| Status | Preview URL |\n| - | - |\n| Done | <a href='https://commit.example.com'>Commit</a><br><a href='https://branch.example.com'>Branch</a> |",
88
+ it("keeps <br> line breaks in a table cell without breaking the row", () => {
89
+ const markdown =
90
+ "| Status | Preview URL |\n| - | - |\n| Done | <a href='https://commit.example.com'>Commit</a><br><a href='https://branch.example.com'>Branch</a> |\n| • One<br/>• Two<BR />**Three** | `<br>` |";
91
+ // md4c decodes the reference to a newline in the cell's text, as remark does.
92
+ expect(markdownForNativeRendering(markdown, ENRICHED_INLINE_FILE_LINK_REGEX)).toContain(
93
+ "| • One • Two **Three** | `<br>` |",
94
);
92
- const table = document.children[0];
95
+ const table = parseMarkdownDocument(markdown).children[0];
96
expect(table?.type).toBe("table");
97
if (table?.type !== "table") return;
95
- expect(table.children).toHaveLength(2);
98
+ expect(table.children).toHaveLength(3);
99
+ expect(table.children.map((row) => row.children.length)).toEqual([2, 2, 2]);
100
expect(table.children[1]?.children[1]?.children).toMatchObject([
101
{ type: "link", url: "https://commit.example.com", children: [{ value: "Commit" }] },
98
- { type: "text", value: " " },
102
+ { type: "text", value: "\n" },
103
{ type: "link", url: "https://branch.example.com", children: [{ value: "Branch" }] },
104
]);
105
+ expect(table.children[2]?.children).toMatchObject([
106
+ { children: [{ value: "• One\n• Two\n" }, { type: "strong" }] },
107
+ { children: [{ type: "inlineCode", value: "<br>" }] },
108
+ ]);
109
});
110
111
it("keeps a table row intact when an anchor href contains a pipe", () => {
@@ -121,7 +129,7 @@ describe("HTML in native Markdown", () => {
129
const markdown =
130
'> **!<a href="https://x.test">[one]</a>** and <span>tail</span>\n\n| A |\n| - |\n| !<a href="https://x.test">x[y]</a><br><img src="x.png"> |';
131
expect(markdownWithHtml(markdown)).toBe(
124
- "> **\\![\\[one\\]](<https://x.test>)** and tail\n\n| A |\n| - |\n| \\![x\\[y\\]](<https://x.test>)  |",
132
+ "> **\\![\\[one\\]](<https://x.test>)** and tail\n\n| A |\n| - |\n| \\![x\\[y\\]](<https://x.test>)  |",
133
);
134
expect(
135
markdownWithHtml(
patches/react-native-enriched-markdown@1.2.0-t3.16.patch
new
+92
@@ -0,0 +1,92 @@
1
+diff --git a/android/src/main/java/com/swmansion/enriched/markdown/segments/TableContainerView.kt b/android/src/main/java/com/swmansion/enriched/markdown/segments/TableContainerView.kt
2
+--- a/android/src/main/java/com/swmansion/enriched/markdown/segments/TableContainerView.kt
3
++++ b/android/src/main/java/com/swmansion/enriched/markdown/segments/TableContainerView.kt
4
+@@ -131,7 +131,7 @@ class TableContainerView(
5
+ TableCellData(
6
+ attributedText = renderCellNode(cell, isHeader, align),
7
+ plainText = extractPlainText(cell),
8
+- markdownText = MarkdownASTSerializer.serializeChildren(cell),
9
++ markdownText = MarkdownASTSerializer.serializeTableCell(cell),
10
+ isHeader = isHeader,
11
+ alignment = align,
12
+ )
13
+diff --git a/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt b/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt
14
+--- a/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt
15
++++ b/android/src/main/java/com/swmansion/enriched/markdown/utils/common/serialization/MarkdownASTSerializer.kt
16
+@@ -20,6 +20,12 @@ object MarkdownASTSerializer {
17
+ return buffer.toString()
18
+ }
19
+
20
++ private val tableCellLineBreak = Regex("""(?<!\\)(\\*)\n""")
21
++
22
++ /** Serializes a table cell's content; a newline inside it becomes `<br>` so the row stays on one line. */
23
++ fun serializeTableCell(cell: MarkdownASTNode): String =
24
++ serializeChildren(cell).replace(tableCellLineBreak, "$1$1<br>")
25
++
26
+ /**
27
+ * Serializes a Blockquote or Admonition node back to markdown, including
28
+ * the `> ` prefix on every line and `> [!TYPE]` header for admonitions.
29
+@@ -179,7 +185,7 @@ object MarkdownASTSerializer {
30
+ for (section in node.children) {
31
+ for (row in section.children) {
32
+ if (row.type != NodeType.TableRow) continue
33
+- val cells = row.children.map { serializeChildren(it) }
34
++ val cells = row.children.map { serializeTableCell(it) }
35
+ buffer.append("| ")
36
+ buffer.append(cells.joinToString(" | "))
37
+ buffer.append(" |\n")
38
+diff --git a/ios/segments/TableContainerView.m b/ios/segments/TableContainerView.m
39
+--- a/ios/segments/TableContainerView.m
40
++++ b/ios/segments/TableContainerView.m
41
+@@ -163,7 +163,7 @@ static NSArray<NSArray<TableCellData *> *> *ENRMTableBuildRows(MarkdownASTNode *
42
+ cell.isHeader = isSectionHead || (cellNode.type == MarkdownNodeTypeTableHeaderCell);
43
+ cell.alignment = ENRMTableTextAlignmentFromString(cellNode.attributes[@"align"]);
44
+ cell.plainText = ENRMTablePlainTextFromNode(cellNode);
45
+- cell.markdownText = markdownFromASTNodeChildren(cellNode);
46
++ cell.markdownText = markdownFromTableCellNode(cellNode);
47
+
48
+ StyleConfig *cellConfig = cell.isHeader ? headerCellConfig : bodyCellConfig;
49
+ cell.attributedText =
50
+diff --git a/ios/utils/MarkdownASTSerializer.h b/ios/utils/MarkdownASTSerializer.h
51
+--- a/ios/utils/MarkdownASTSerializer.h
52
++++ b/ios/utils/MarkdownASTSerializer.h
53
+@@ -17,6 +17,9 @@ NSString *markdownFromASTNode(MarkdownASTNode *node);
54
+ /// Useful for extracting the markdown content of a container node (e.g. a table cell).
55
+ NSString *markdownFromASTNodeChildren(MarkdownASTNode *node);
56
+
57
++/// Serializes a table cell's content; a newline inside it becomes `<br>` so the row stays on one line.
58
++NSString *markdownFromTableCellNode(MarkdownASTNode *node);
59
++
60
+ /// Serializes a Blockquote or Admonition node to full markdown, including `> ` line
61
+ /// prefixes and `> [!TYPE]` header for admonitions.
62
+ NSString *markdownFromBlockquoteNode(MarkdownASTNode *node);
63
+diff --git a/ios/utils/MarkdownASTSerializer.m b/ios/utils/MarkdownASTSerializer.m
64
+--- a/ios/utils/MarkdownASTSerializer.m
65
++++ b/ios/utils/MarkdownASTSerializer.m
66
+@@ -148,7 +148,7 @@ static void appendTableMarkdown(MarkdownASTNode *node, NSMutableString *buffer)
67
+ continue;
68
+ NSMutableArray<NSString *> *cells = [NSMutableArray arrayWithCapacity:row.children.count];
69
+ for (MarkdownASTNode *cell in row.children) {
70
+- [cells addObject:markdownFromASTNodeChildren(cell)];
71
++ [cells addObject:markdownFromTableCellNode(cell)];
72
+ }
73
+ [buffer appendFormat:@"| %@ |\n", [cells componentsJoinedByString:@" | "]];
74
+ if (!headerDone) {
75
+@@ -333,6 +333,17 @@ NSString *markdownFromASTNodeChildren(MarkdownASTNode *node)
76
+ return [buffer copy];
77
+ }
78
+
79
++NSString *markdownFromTableCellNode(MarkdownASTNode *node)
80
++{
81
++ NSString *markdown = markdownFromASTNodeChildren(node);
82
++ if (![markdown containsString:@"\n"])
83
++ return markdown;
84
++ return [markdown stringByReplacingOccurrencesOfString:@"(?<!\\\\)(\\\\*)\n"
85
++ withString:@"$1$1<br>"
86
++ options:NSRegularExpressionSearch
87
++ range:NSMakeRange(0, markdown.length)];
88
++}
89
++
90
+ NSString *markdownFromBlockquoteNode(MarkdownASTNode *node)
91
+ {
92
+ if (!node)
pnpm-lock.yaml
+3
-2
@@ -382,6 +382,7 @@ patchedDependencies:
382
micromark-extension-llm-math@3.1.0: 4eeb9d9e27ebc75e98795e21c0719005483dad7d233055698257f7d10e91603b
383
micromark@4.0.2: cb79edde7eca83bbcaaafb6ceb7b044b81b987314cde4910823b15257ecada67
384
node-pty@1.2.0-beta.15: f1e680afec85f650699ea756f91f469844ec4c976f4f168492a45c6b3f67d651
385
+ react-native-enriched-markdown@1.2.0-t3.16: 542e6932066897941f54b902fa7823b2a1861c4a741b5369d5c2d49bd18485a2
386
react-native-gesture-handler@3.3.0: abe20e1d1c23549297cbbc818e14fe479b41455930d9663135d6b40fe359b626
387
react-native-image-viewing@0.2.2: 4aa038d541c7ddcc8f1437eb3e7b4f769f61de78e7f91b53f9805dfca608474d
388
react-native-keyboard-controller@1.22.8: 4e9b5a52aa8c1f9de8082bad281ee979df7860fc77ec49820d4ed00c3c7cc5a2
@@ -736,7 +737,7 @@ importers:
737
version: 0.25.1(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
738
react-native-enriched-markdown:
739
specifier: file:deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz
739
- version: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz(katex@0.16.47)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
740
+ version: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz(patch_hash=542e6932066897941f54b902fa7823b2a1861c4a741b5369d5c2d49bd18485a2)(katex@0.16.47)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
741
react-native-gesture-handler:
742
specifier: 3.3.0
743
version: 3.3.0(patch_hash=abe20e1d1c23549297cbbc818e14fe479b41455930d9663135d6b40fe359b626)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
@@ -21248,7 +21249,7 @@ snapshots:
21249
react: 19.3.0
21250
react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
21251
21251
- react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz(katex@0.16.47)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0):
21252
+ react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz(patch_hash=542e6932066897941f54b902fa7823b2a1861c4a741b5369d5c2d49bd18485a2)(katex@0.16.47)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0):
21253
dependencies:
21254
react: 19.3.0
21255
react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
pnpm-workspace.yaml
+2
@@ -262,6 +262,8 @@ patchedDependencies:
262
# Observe the owned host exit independently of descendants retaining its stdio.
263
"@muse-code/sdk@1.4.6": patches/@muse-code__sdk@1.4.6.patch
264
app-builder-lib@26.16.1: patches/app-builder-lib@26.16.1.patch
265
+ # A newline in a copied table cell becomes <br>, so Copy as Markdown keeps the row whole.
266
+ react-native-enriched-markdown@1.2.0-t3.16: patches/react-native-enriched-markdown@1.2.0-t3.16.patch
267
# A failed Artifacts.cached effect hangs every later caller: https://github.com/alchemy-run/alchemy/issues/2981
268
alchemy@2.0.0-beta.85: patches/alchemy@2.0.0-beta.85.patch
269