-
Notifications
You must be signed in to change notification settings - Fork 185
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
feat: render table with lipgloss #262
Conversation
ae36c86
to
a92f0f0
Compare
I still don't know why the one test is failing, but I've added a basic padded cell style and support text styling for the cells. I wonder if using renderText for styling the text is the best call. It might end up making more sense to have the styling separate from writing so it's easier to amend styles throughout the program. |
Going to work on margin support in another PR - the scope of this one is just table rendering |
26d655f
to
711848c
Compare
I believe this is using the Lip Gloss table in its pre-release state, so will need to tidy this up a bit before she's ready 2 rock |
renderText(ctx.table.styleWriter, ctx.options.ColorProfile, style, rules.Prefix) | ||
ctx.table.writer = tablewriter.NewWriter(ctx.table.styleWriter) | ||
renderText(w, ctx.options.ColorProfile, style, rules.Prefix) | ||
ctx.table.lipgloss = table.New().StyleFunc(func(row, col int) lipgloss.Style { return cellStyle }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested the PR on some of the large tables that I'd like to display with it and it already looks a lot better! However, I noticed that the width is not properly set, this does the trick:
ctx.table.lipgloss = table.New().StyleFunc(func(row, col int) lipgloss.Style { return cellStyle }) | |
ctx.table.lipgloss = table.New(). | |
StyleFunc(func(row, col int) lipgloss.Style { return cellStyle }). | |
Width(int(ctx.blockStack.Width(ctx))) |
The downside is that it causes columns which contain rows with long text1 to be truncated or even omitted entirely. I'd prefer if it either wraps text within the cell or the table is printed in full width (which isn't really possible because it seems like glamour cuts off the lines, trying to wrap them?). But this is probably a feature request towards lipgloss and not glamour.
Footnotes
Maybe before it's considered perfect you could release this as a TermRendererOption (WithLipglossTableRenderer)? And then when you are satisfied, you can deprecate that option and noop it? |
closes #262 Co-authored-by: bashbunni <[email protected]>
* wip Signed-off-by: Carlos Alexandro Becker <[email protected]> * wip * wip * wip * fix: autolink closes #290 * fix: escape characters closes #106 closes #274 closes #311 * fix: table * ci: golangci lint update * feat: use x/golden * test: #106 Signed-off-by: Carlos Alexandro Becker <[email protected]> * test: #290 Signed-off-by: Carlos Alexandro Becker <[email protected]> * test: #312 Signed-off-by: Carlos Alexandro Becker <[email protected]> * test: #257 Signed-off-by: Carlos Alexandro Becker <[email protected]> * test: #149 * fix: #239 * feat: use lipgloss table closes #262 Co-authored-by: bashbunni <[email protected]> * fix: codespan is not a block * test: #315 * test: #316 * fix: #316 * test: table * fix: codespans, tables * test: table * test: #117 * test: #60 * fix: rm stylewriter * fix: #313 * fix: margin * fix: blocks and word wrap * fix: build Signed-off-by: Carlos Alexandro Becker <[email protected]> * chore: gitattributes * fix: test opt Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: stable lipgloss Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: double styles * fix: tables * fix: tables --------- Signed-off-by: Carlos Alexandro Becker <[email protected]> Co-authored-by: bashbunni <[email protected]>
This is still a wip, but making a draft PR so it's easier to get feedback and help debugging along the way.
It seems to spit out the right table most of the time, but I'd still like to...
StyleWriter
dep in tableansi/TestRendererIssues/46_2