Skip to content

Commit 02721c1

Browse files
committed
Fix broken right border in CLI extended help tables with inline code
Table cells containing inline code backticks (e.g. the cooldown package manager config table) broke the right border alignment in the CLI. cli-table3 computed column widths including the backtick characters, but renderExtendedHelp strips all backticks from the output afterward via uncode, shifting the text and misaligning the border. Strip backticks from cells before computing the layout so widths are calculated against the actual rendered text.
1 parent 06c99c0 commit 02721c1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/lib/table.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ const table = ({
2323
}
2424
// otherwise use cli-table3
2525
else {
26+
// Strip inline code backticks before computing the layout. In the CLI, backticks are removed
27+
// from the extended help output after the table is rendered, so including them here would
28+
// throw off cli-table3's column width calculation and break the right border alignment.
29+
const uncodedRows = rows.map(cells => cells.map(cell => cell.replace(/`/g, '')))
2630
const t = new Table({ ...(colAligns ? { colAligns } : null) })
27-
t.push(...(markdown ? rows : wrapRows(rows)))
31+
t.push(...wrapRows(uncodedRows))
2832
return t.toString()
2933
}
3034
}

0 commit comments

Comments
 (0)