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

Render tables #2

Closed
swsnr opened this issue Jan 7, 2018 · 14 comments
Closed

Render tables #2

swsnr opened this issue Jan 7, 2018 · 14 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@swsnr
Copy link
Owner

swsnr commented Jan 7, 2018

Need a good library to render tables to TTY?

@swsnr swsnr added the help wanted Extra attention is needed label Jan 16, 2018
@frcl
Copy link

frcl commented Feb 11, 2018

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:

┌─────┬─────┬─────┐
│ A   │ B   │ C   │
├─────┼─────┼─────┤
│ foo │ bar │ baz │
└─────┴─────┴─────┘

(In the terminal it looks nicer. I get gaps between lines in the browser, which shouln't be there.)

@swsnr
Copy link
Owner Author

swsnr commented Feb 12, 2018

Thanks for the pointer, @frcl, I'll take a look.

@swsnr swsnr added enhancement New feature or request and removed enhancement New feature or request labels Jan 6, 2019
@ericonr
Copy link

ericonr commented Apr 15, 2020

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?

@swsnr
Copy link
Owner Author

swsnr commented Apr 15, 2020

@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 😉 )

@norman-abramovitz
Copy link
Contributor

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.

@nicolaipre
Copy link

Are there any recent plans to add support for this in mdcat?

@swsnr
Copy link
Owner Author

swsnr commented Dec 14, 2020

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.

@norman-abramovitz
Copy link
Contributor

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.

@DrSensor
Copy link

DrSensor commented Jun 19, 2021

Check out termimad!
It's all-in-one crate for rendering markdown in terminal. Wrapping, table balancing, and scrolling are essential features of termimad.

@brian6932

This comment was marked as off-topic.

@swsnr
Copy link
Owner Author

swsnr commented Nov 10, 2021

No there's not. If there was you'd see it. Meanwhile, pull requests welcome. My last comment still stands.

@snaggen
Copy link

snaggen commented Oct 18, 2023

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.

@swsnr
Copy link
Owner Author

swsnr commented Oct 18, 2023

Closing this, because I don't intend to do implement table support any time soon.

Pull requests are welcome.

@swsnr swsnr closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2023
@jimcornmell

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

9 participants