-
Notifications
You must be signed in to change notification settings - Fork 69
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
Render tables #2
Comments
The prettytable is quite nice. The default rendering style is orgmode like, but I recently discoverd that with its formatting features and a few special characters you can do somethinng like this: #[macro_use] extern crate prettytable;
use prettytable::format::{TableFormat,LinePosition,LineSeparator};
let mut format = TableFormat::new();
format.column_separator('│');
format.borders('│');
format.separator(LinePosition::Top, LineSeparator::new('─', '┬', '┌', '┐'));
format.separator(LinePosition::Title, LineSeparator::new('─', '┼', '├', '┤'));
format.separator(LinePosition::Intern, LineSeparator::new('─', '┼', '├', '┤'));
format.separator(LinePosition::Bottom, LineSeparator::new('─', '┴', '└', '┘'));
format.padding(1, 1);
// Example
let mut table = table!(["A", "B", "C"],
["foo", "bar", "baz"]);
table.set_format(format);
table.printstd(); That will print the table like this:
(In the terminal it looks nicer. I get gaps between lines in the browser, which shouln't be there.) |
Thanks for the pointer, @frcl, I'll take a look. |
I'd like to take a crack at it! Do you think the program would have to detect if the terminal properly supports Unicode, or would it be ok to use it directly? And do you have any idea about how wrapping a table would work? Or can that situation be ignored? |
@ericonr You can assume a modern terminal with decent font, unicode and all. It's 2020 after all. As for wrapping, no, I don't. That's something you'll need to figure out if you'd like to try it. I don't know how it could look like, it just needs to, well, kinda work for the general case, as measured by my gut feeling 😉 ) |
Maybe something like html-table-to-markdown-converter. An then we can write a simple display module. I am assuming the pushdown_markdown parser generates HTML. Maybe this converter could be used when we see a Hmtl table as well. |
Are there any recent plans to add support for this in mdcat? |
No, I do not have any such plans, hence the "Help wanted" label. This won't get done any time soon unless some opens a good pull request about it. |
I am thinking of working on this issue during my holiday/lockdown break. It will depend on my availability with my family. I will need to familiarize myself with all the latest changes first. |
This comment was marked as off-topic.
This comment was marked as off-topic.
No there's not. If there was you'd see it. Meanwhile, pull requests welcome. My last comment still stands. |
Just tested mdcat with https://github.com/sainnhe/gruvbox-material/blob/master/README.md and that did not go well... uses images inside of tables. So I guess, that might be a good test case. |
Closing this, because I don't intend to do implement table support any time soon. Pull requests are welcome. |
Need a good library to render tables to TTY?
The text was updated successfully, but these errors were encountered: