Skip to content

Commit 6785a8d

Browse files
authored
Merge pull request #2463 from mj4444ru/patch-1
Fix Markdown table cell separator escaping in MarkdownDisplay.tsx
2 parents 294afdf + d76451a commit 6785a8d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/cli/src/ui/utils/MarkdownDisplay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const MarkdownDisplayInternal: React.FC<MarkdownDisplayProps> = ({
111111
lines[index + 1].match(tableSeparatorRegex)
112112
) {
113113
inTable = true;
114-
tableHeaders = tableRowMatch[1].split('|').map((cell) => cell.trim());
114+
tableHeaders = tableRowMatch[1].split(/(?<!\\)\|/).map((cell) => cell.trim().replaceAll('\\|', '|'));
115115
tableRows = [];
116116
} else {
117117
// Not a table, treat as regular text
@@ -127,7 +127,7 @@ const MarkdownDisplayInternal: React.FC<MarkdownDisplayProps> = ({
127127
// Skip separator line - already handled
128128
} else if (inTable && tableRowMatch) {
129129
// Add table row
130-
const cells = tableRowMatch[1].split('|').map((cell) => cell.trim());
130+
const cells = tableRowMatch[1].split(/(?<!\\)\|/).map((cell) => cell.trim().replaceAll('\\|', '|'));
131131
// Ensure row has same column count as headers
132132
while (cells.length < tableHeaders.length) {
133133
cells.push('');

packages/cli/src/ui/utils/TableRenderer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export const TableRenderer: React.FC<TableRendererProps> = ({
3535

3636
// Ensure table fits within terminal width
3737
const totalWidth = columnWidths.reduce((sum, width) => sum + width + 1, 1);
38-
const scaleFactor = totalWidth > contentWidth ? contentWidth / totalWidth : 1;
38+
const fixedWidth = columnWidths.length + 1;
39+
const scaleFactor = totalWidth > contentWidth ? (contentWidth - fixedWidth) / (totalWidth - fixedWidth) : 1;
3940
const adjustedWidths = columnWidths.map((width) =>
4041
Math.floor(width * scaleFactor),
4142
);

0 commit comments

Comments
 (0)