Textualize / rich-cli

Rich-cli is a command line toolbox for fancy output in the terminal
https://www.textualize.io
MIT License
2.99k stars 77 forks source link

Request: turn markdown tables into Rich tables #36

Closed treyhunner closed 2 years ago

treyhunner commented 2 years ago

I wanted to show a nicely formatted visual table within my terminal for a screencast I'm recording. I thought "I could use Rich for that". But then I remembered that I already have a markdown table that represents exactly what I'd like to show, so I decided to try using rich-cli with my markdown file instead.

I tried rich -m markdown_file_with_table.md and it just showed all the | and - smooshed together.

Here's an example markdown table:

| Features    | rich | markdown | rich-cli |
|-------------|:----:|:--------:|:--------:|
| has tables  | x    | x        |          |
| easy to use | x    | x        | x        |

And output:

Features rich markdown rich-cli
has tables x x
easy to use x x x
willmcgugan commented 2 years ago

Hi Trey,

The markdown parser we use in Rich (commonmark) doesn't support tables. There are some better alternatives now, so at some point we will replace that lib and get Markdown tables.

Closing, because its on the cards of Rich.

daviewales commented 11 months ago

Rich now supports tables! https://github.com/Textualize/rich/releases/tag/v13.4.0

I'm guessing rich-cli just needs to update to the latest version of rich to make this work?

Update: I've got a fork here with bumped dependencies which seems to work: https://github.com/daviewales/rich-cli/ You can install it with:

pipx install rich-cli@git+https://github.com/daviewales/rich-cli.git

Happy to turn this into a PR if it would be accepted.