-
Notifications
You must be signed in to change notification settings - Fork 193
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
Max column width for tables #344
Comments
Any news/comment on this from the maintainer team? This is a real blocker for us Thanks! |
Hey, @testinfected! Thanks for the follow-up, and apologies for the delay here. Can you post some example code (and ideally some screenshots). As simple as it might seem, this will greatly help us in looking into this. |
Seconding meow's comment above. If I'm understanding the issue correctly, you're looking to add width constraints to the table? If so, you can set that with That said, this is just a guess at what you're hoping to achieve here. Example code would definitely help us better understand what you're looking for :) defaultWidth := 80
// ...
// Create a new renderer.
r, err := glamour.NewTermRenderer(
glamour.WithEnvironmentConfig(),
glamour.WithWordWrap(defaultWidth), glamour/examples/stdin-stdout-custom-styles/main.go Lines 30 to 32 in 9cedaca
|
I will post some screenshots. I already tried word wrap, but it ellipsis the string (if that's even a word) instead of wrapping to a new line. Am I missing something? |
ping |
Ah okay, thank you for the screenshots, those are super helpful. We will look into it and keep you updated here |
@bashbunni sorry to ping again, do you have any news on this? |
Sorry for the hold-up on this, @testinfected. Wow, this is really, really bad. We're looking into this. Here's the full source code to reproduce this. go get github.com/MakeNowJust/heredoc
go get github.com/charmbracelet/glamour package main
import (
"fmt"
"os"
"github.com/MakeNowJust/heredoc"
"github.com/charmbracelet/glamour"
)
var md = heredoc.Doc(`
|Name|Description|Type|Required|Default|
|----|-----------|----|--------|-------|
|command|A command to be executed inside the container to assess its health. Each space delimited token of the command is a separate array element. Commands exiting 0 are considered to be successful probes, whilst all other exit codes are considered failures.|[`string`]|yes||
`)
func main() {
r, err := glamour.NewTermRenderer(
glamour.WithEnvironmentConfig(),
glamour.WithWordWrap(80),
)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create renderer: %v", err)
os.Exit(1)
}
var out string
out, err = r.Render(md)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to render markdown: %v", err)
os.Exit(1)
}
fmt.Println(out)
} |
Off the cuff, it looks like a few things need to happen:
|
Update: made some good progress on this. Needs more refinement though and need to add some tests for edge cases. Just wanted to let you know we are thinking about it and actively working on it :) |
Thanks so much for working on this. I’m looking forward to be able to update to 0.8, it has so many nice improvements over 0.7 |
Since the last update using lipgloss to render tables, it's no longer possible to have columns with a max width and text wrapping, unless I'm missing something. This produces some pretty awful rendering of tables that expand to take the entire terminal width or else cut their cell content instead of wrapping.
We'd like to be able to set a max column width and decide if we wrap or cut content (with ellipsis).
An alternative would be to have multiline cells, using for instance line breaks in the cell content itself. Obviously this wouldn't be controlled by style, but still acceptable.
The text was updated successfully, but these errors were encountered: