-
Notifications
You must be signed in to change notification settings - Fork 184
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
Extra new lines between list items when word wrap is set to terminal width #331
Comments
I've done some debugging to understand what is happening using this sample: * Bullet 1
* Bullet 2
* A bullet which is way to long to fit in a single line, so it has to be
wrapped in the source as well as in the rendered output. Output (run using md, strip ansi codes, show width, you must use the GNU version of sed and awk):
Wrapping of the text is done in github.com/charmbracelet/x/ansi.Wordwrap, the function is called here with There is also this weird effect that the newline gets preserved within the bullet which seems odd and the continuation of the bullet should be indented but this is the same with <0.8.0. The issue seems to be introduced with 5f5965e, reverting it locally and re-running my test from above yields this result:
I think it could be this line, changing the width calculation back to // Width returns the available rendering width.
func (s BlockStack) Width(ctx RenderContext) uint {
if s.Indent()+s.Margin() > uint(ctx.options.WordWrap) {
return 0
}
return uint(ctx.options.WordWrap) - s.Indent() - s.Margin()
} Because the indent is Result (with 0.8.0 + my fix):
As you can see the margin calculation is still off, it should probably be I've opened #343. |
I just noticed that we do need the
|
Describe the bug
New with v0.8.0! When using a custom renderer with word wrap set to the full terminal width using glamour.WithWordWrap(), extra blank lines are printed between list items.
Setup
To Reproduce
Steps to reproduce the behavior:
Source Code
I wrote a demo program that creates a renderer and renders a couple lists. If using Glamour v0.7.0, they render correctly. If using Glamour v0.8.0, they appear broken and have extra new lines between them.
Screenshots
v0.8.0
v0.7.0
Additional Context
Subtracting from the full width only very inconsistently solves the issue. Depending on the document and total terminal width, a different value needs to be subtracted from the terminal width to mitigate the bug. Sometimes I can fix it by using width-2, other times I need width-5 or other.
The text was updated successfully, but these errors were encountered: