Skip to content

Corrupted table due to spanning and drawHorizontalLine #232

@sorawee

Description

@sorawee

Consider the following code:

import { table } from "table";

console.log(
    table([
        ["abc", "abc", " "],
        [" ",   "abc", " "],
        [" ",   "abc", " "],
        [" ",   "abc", "abc"],
    ], 
    {
        spanningCells: [
            { row: 0, col: 0, rowSpan: 4 },
            { row: 0, col: 1, colSpan: 2 },
            { row: 1, col: 1, colSpan: 2 },
            { row: 2, col: 1, colSpan: 2 },
        ],
        columns: { 
            0: { width: 3 },
            1: { width: 3 },
            2: { width: 3 },
        },
        drawHorizontalLine: (row) => [0, 3, 4].includes(row)
    })
);

Actual output:

╔═════╤═══════════╗
║ abc │ abc       ║
║     │ abc       ║
║     │ abc       ║
║├─────┬─────╢
║     │ abc │ abc ║
╚═════╧═════╧═════╝

Expectation:

╔═════╤═══════════╗
║ abc │ abc       ║
║     │ abc       ║
║     │ abc       ║
║     ├─────┬─────╢
║     │ abc │ abc ║
╚═════╧═════╧═════╝

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions