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

APIv4 --out=table prints a non-markdown-compatible table #182

Open
colemanw opened this issue Oct 19, 2023 · 1 comment
Open

APIv4 --out=table prints a non-markdown-compatible table #182

colemanw opened this issue Oct 19, 2023 · 1 comment

Comments

@colemanw
Copy link
Member

What would it take for the table output to be compatible with markdown? That seems like a more useful format?

Currently the table output looks like this:

+-------+----------------+----------------+
| value | name           | label          |
+-------+----------------+----------------+
| 1     | Completed      | Completed      |
| 2     | Pending        | Pending        |
| 3     | Cancelled      | Cancelled      |
| 4     | Failed         | Failed         |
| 7     | Refunded       | Refunded       |
| 8     | Partially paid | Partially paid |
| 9     | Pending refund | Pending refund |
| 10    | Chargeback     | Chargeback     |
| 11    | Template       | Template       |
+-------+----------------+----------------+

Which is nice-looking ascii art, but when you paste it into GitLab, GitHub or any other type of markdown document, it looks like this:

+-------+----------------+----------------+
| value | name | label |
+-------+----------------+----------------+
| 1 | Completed | Completed |
| 2 | Pending | Pending |
| 3 | Cancelled | Cancelled |
| 4 | Failed | Failed |
| 7 | Refunded | Refunded |
| 8 | Partially paid | Partially paid |
| 9 | Pending refund | Pending refund |
| 10 | Chargeback | Chargeback |
| 11 | Template | Template |
+-------+----------------+----------------+

@totten
Copy link
Member

totten commented Oct 20, 2023

Markdown compat is a neat idea

FWIW, the table is rendered using Symfony's Table helper:

My guess is that either (a) there's some kind of existing "style"/renderer for Markdown or (b) you could tune options like setDefaultCrossingChar('|') to make a Markdown-friendly layout. The main thing to look out for is line-wrapping data -- iirc, Markdown's text doesn't really allow wrapping. This would be a colorful demonstration where I think they diverge:

cv api4 MessageTemplate.get -T +s id,msg_html +l 2

There are a few alternate possibilities:

  1. If there's a format that handles newlines suitably for both text-console and Markdown-renderers, then change the current table output to use that.
  2. Tweak the current the output to be closer to Markdown in the average case (single-line content) and accept that some output won't transfer over to *.md.
  3. Provide an alternate output (--out=md) optimized for Markdown. (This might allow for other adaptations, like backtick escaping?)

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

No branches or pull requests

2 participants