@xynogen/pix-display 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/tables.ts +7 -2
package/package.json
CHANGED
package/src/tables.ts
CHANGED
|
@@ -12,6 +12,7 @@ type RenderTable = (
|
|
|
12
12
|
|
|
13
13
|
const NATIVE = Symbol.for("@xynogen/pix-display:native-render-table");
|
|
14
14
|
const CORNERS: Record<string, string> = { "┌": "╭", "┐": "╮", "└": "╰", "┘": "╯" };
|
|
15
|
+
const HEAVY: Record<string, string> = { "├": "┝", "─": "━", "┼": "┿", "┤": "┥" };
|
|
15
16
|
// Pi pads each cell with plain spaces, sometimes inside its closing style codes.
|
|
16
17
|
const TRAILING_PAD_RE = /(?: |\x1b\[[0-9;]*m)+$/;
|
|
17
18
|
// Same text-style reset Pi uses between wrapped cell fragments; the slice drops a
|
|
@@ -29,7 +30,8 @@ function alignCell(cell: string, width: number, align: Align | undefined): strin
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
* Restyle Pi's box table: dim rounded borders, column alignment
|
|
33
|
+
* Restyle Pi's box table: dim rounded borders, column alignment, an accent header and a
|
|
34
|
+
* heavy rule under it.
|
|
33
35
|
* No background fill: a cell-wide fill overhangs the half-cell `│` borders, and some
|
|
34
36
|
* themes and terminals show it barely or not at all, so the table looks the same everywhere.
|
|
35
37
|
*/
|
|
@@ -50,7 +52,10 @@ export function styleTable(
|
|
|
50
52
|
let header = true;
|
|
51
53
|
return lines.map((line) => {
|
|
52
54
|
if (!line.startsWith("│")) {
|
|
53
|
-
if (line.startsWith("├"))
|
|
55
|
+
if (header && line.startsWith("├")) {
|
|
56
|
+
header = false;
|
|
57
|
+
return border(line.replace(/[├─┼┤]/g, (c) => HEAVY[c] ?? c));
|
|
58
|
+
}
|
|
54
59
|
return line && border(line.replace(/^[┌└]|[┐┘]$/g, (c) => CORNERS[c] ?? c));
|
|
55
60
|
}
|
|
56
61
|
let col = 2;
|