Skip to content

Commit a8af23e

Browse files
fix(client-runtime): media tables with indented cells split line by line
Indented HTML in a cell would render as a markdown code block once the cell is split on its own, so such tables keep main's line-by-line split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5024f4c commit a8af23e

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎packages/client-runtime/src/pullRequestMarkdown.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ describe("media tables", () => {
239239
],
240240
["an unclosed table", "<table>\n<tr><td>", ""],
241241
["a spanning cell", '<table>\n<tr><td colspan="2">', "</td></tr>\n</table>"],
242+
[
243+
"an indented cell",
244+
"<table>\n <tr>\n <th>\n Before\n </th>\n </tr>\n <tr><td>",
245+
"</td></tr>\n</table>",
246+
],
242247
])("splits a media table with %s line by line, as before", (_name, open, close) => {
243248
const body = `${open}\n\n${video}\n\n${close}`;
244249
expect(splitPullRequestBody(body)).toEqual([

‎packages/client-runtime/src/pullRequestMarkdown.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ function tableRows(html: string, htmlOffset: number): TableRows | null {
100100
const tag = match[2]!.toLowerCase();
101101
if (cell !== null) {
102102
if (!closing || tag !== cell.tag) return null;
103+
const content = html.slice(cell.contentStart, match.index);
104+
// Indented HTML would render as a code block once the cell is markdown on its own.
105+
if (content.split("\n").some((line) => INDENTED_CODE_PATTERN.test(line) && line.trim()))
106+
return null;
103107
row!.push({
104108
header: tag === "th",
105-
segments: splitBodyAt(
106-
html.slice(cell.contentStart, match.index),
107-
htmlOffset + cell.contentStart,
108-
),
109+
segments: splitBodyAt(content, htmlOffset + cell.contentStart),
109110
});
110111
cell = null;
111112
} else {

0 commit comments

Comments
 (0)