JakeWharton / picnic

A Kotlin DSL and Java/Kotlin builder API for constructing HTML-like tables which can be rendered to text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support horizontal rule

garfieldnate opened this issue · comments

In the tables I'm generating, I have several sections. It would useful to be able to add a separator between these sections.

And you don't want to use separate tables because you want all of their columns to align?

Do you have an example output that you think would make sense so I can get an idea of what you mean exactly?

Yep, I'd like all of the columns to align. The context is that I'm porting a Perl project to Java. Here's the printout I have from the Perl module: https://metacpan.org/source/NGLENN/Algorithm-AM-3.11/t%2F04-Result.t#L223; the *** lines are rules (I use https://metacpan.org/pod/Text::Table, which provides a rule method). I know this one is ugly; I think Picnic can do better using the unicode box drawing characters, since there are already characters available for double lines or, probably a better choice, bold lines (U+251D, etc.).

My current printout with picnic is as follows:

┌────────────┬──────────┬───────────┬───────┬─────────┐
│ Percentage │ Pointers │ Num Items │ Class │ Context │
├────────────┼──────────┼───────────┼───────┼─────────┤
│    %61.538 │        8 │         2 │       │   3 1 * │
├────────────┼──────────┼───────────┼───────┼─────────┤
│    %30.769 │        4 │         1 │     e │         │
│            │          │           │       │   3 1 0 │
│    %30.769 │        4 │         1 │     r │         │
│            │          │           │       │   3 1 1 │
├────────────┼──────────┼───────────┼───────┼─────────┤
│    %23.077 │        3 │         1 │       │   * 1 2 │
├────────────┼──────────┼───────────┼───────┼─────────┤
│    %23.077 │        3 │         1 │     r │         │
│            │          │           │       │   2 1 2 │
├────────────┼──────────┼───────────┼───────┼─────────┤
│    %15.385 │        2 │         1 │       │   * * 2 │
├────────────┼──────────┼───────────┼───────┼─────────┤
│    %15.385 │        2 │         1 │     r │         │
│            │          │           │       │   0 3 2 │
└────────────┴──────────┴───────────┴───────┴─────────┘

The rows with 3 1 *, * 1 2 and * * 2 in the Context column are meant to start their own sections in the table.