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

Show-Markdown command fails displaying a markdown table #17984

Open
5 tasks done
tim-krehan opened this issue Aug 29, 2022 · 4 comments
Open
5 tasks done

Show-Markdown command fails displaying a markdown table #17984

tim-krehan opened this issue Aug 29, 2022 · 4 comments
Labels
Needs-Triage The issue is new and needs to be triaged by a work group. WG-Cmdlets-Utility cmdlets in the Microsoft.PowerShell.Utility module

Comments

@tim-krehan
Copy link

Prerequisites

Steps to reproduce

@"
| table | header |
| --- | --- |
| this | is |
| my | data |
"@ | Show-Markdown

Expected behavior

Some kind of visualisation using ascii chars. For example with box drawing chars (https://en.wikipedia.org/wiki/Box-drawing_character):
┌───────┬────────┐
│ table │ header │
│───────╀────────│
│ this  │ is     │
│ my    │ data   │
└───────┴────────┘

Actual behavior

It just outputs a string with the markwodn in one line:

PS> | table | header | | --- | --- | | this | is | | my | data |

Error details

There is no error

Environment data

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@tim-krehan tim-krehan added the Needs-Triage The issue is new and needs to be triaged by a work group. label Aug 29, 2022
@dkaszews
Copy link
Contributor

Likely not a bug per se, just was never implemented. Sounds like a good issue for new implementers, simply iterate through all rows once to get max column widths, then iterate second time to actually print with appropriate padding and alignment.

Couple opens:

  1. How should we handle tables wider than terminal? Truncate, wrap, wrap within cell? User configurable?
  2. Do we really want to use box drawing characters, or should we stick to more reliable set of |+-? Maybe allow user to provide character set for it to be most portable?

More general issue to be handled separately, but may as well put it here to keep it in mind: I was playing with Show-Markdown and am not really satisfied with the colors it uses for things like headers, we should add a style configuration using ANSI escapes, either as a parameter or inside $PSStyle.

@237dmitry
Copy link

I think this cmdlet is a tool to launch default browser to show markdown data. No tables, no hyperlinks. You can customize output with Set-MarkdownOption (including links with OSC sequence if terminal can) but not the tables. And I agree, tables can be wider than the console buffer.

@dkaszews
Copy link
Contributor

Did not know about Set-MarkdownOptions which solves my last issue. It would probably be a good place to store table rendering options, like header font, drawing characters and wrapping behavior. You could probably steal a lot of code from Format-Table.

@daxian-dbw daxian-dbw added the WG-Cmdlets-Utility cmdlets in the Microsoft.PowerShell.Utility module label Aug 30, 2022
@rickandersen1968
Copy link

As mentioned by @dkaszews, formatting tables using the same logic as Format-Table would be good enough for most cases. At least for me, this would be very useful if it could be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Triage The issue is new and needs to be triaged by a work group. WG-Cmdlets-Utility cmdlets in the Microsoft.PowerShell.Utility module
Projects
None yet
Development

No branches or pull requests

5 participants