Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to skip left and right borders #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rovo89
Copy link
Contributor

@rovo89 rovo89 commented Jun 10, 2022

Similar to top_and_tail, this adds an option to remove the left and right borders. It works with all three styles.

Example:

use Text::Table::Tiny 1.02 qw/ generate_table /;

my $rows = [
  [qw/ Pokemon     Type     Count /],
  [qw/ Abra        Psychic      5 /],
  [qw/ Ekans       Poison     123 /],
  [qw/ Feraligatr  Water     5678 /],
];

print generate_table(rows => $rows, header_row => 1, left_and_right => 1), "\n";

Will generate the following:

-----------+---------+------
Pokemon    | Type    | Count
-----------+---------+------
Abra       | Psychic | 5
Ekans      | Poison  | 123
Feraligatr | Water   | 5678
-----------+---------+------

Or combined with top_and_tail (for which I introduced a shortcut edges):

print generate_table(rows => $rows, header_row => 1, top_and_tail => 1, left_and_right => 1), "\n";
print generate_table(rows => $rows, header_row => 1, edges => 1), "\n";
Pokemon    | Type    | Count
-----------+---------+------
Abra       | Psychic | 5
Ekans      | Poison  | 123
Feraligatr | Water   | 5678

Note that this is based on #15 for Perl 5.8 compatibility, the actual changes can be seen in d57779d?w=1. If the other PR is not accepted, it's trivial to rebase it to master instead. Also I didn't add documentation and tests yet, happy to do that if there's interest in this enhancement.

@neilb
Copy link
Owner

neilb commented Jun 20, 2022

I'm not sure about the name left_and_right.

The phrase "top and tail" is an established idiom for cutting the top and bottom off something, but "left and righting something" isn't.

I can't think of an obvious alternative so far. Thoughts are

no_sides => 1

which also made me wonder about

no_frame => 1

or

no_border => 1

meaning no orders on any of the sides.

I don't like the no_ in an option which is then set to a truthy value, but may be unavoidable.

@rovo89
Copy link
Contributor Author

rovo89 commented Jun 20, 2022

Ah, as a non-native speaker I didn't know this idiom and was confused why you would enable the top and tail option to actually get rid of them. 😊

I guess some "-less" might sound a little less strange, as in "frameless" or "borderless". But yeah, not easy to find something clwae and precise.

@rovo89
Copy link
Contributor Author

rovo89 commented Jun 20, 2022

Staying with the original idiom, maybe "peel" could mean slicing off the other parts of the fruit. 😉

@neilb
Copy link
Owner

neilb commented Jun 20, 2022

Ha. Ok, I apologise for "top and tail"! :-)

I wonder whether something like:

frame => "none"
frame => "TB"
frame => "TBLR"
frame => "all"

but such a general purpose option seems overkill – who is going to use "TR", for example?

And I was thinking, would "NSEW" be better than "TBLR"?

I'll mull some more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants