-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Change default markdown wrap limit from 80 to 120 #6016
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
Conversation
The default word wrap limit in Glamour is 80, see charmbracelet/glamour#161 This causes problems rendering hard-wrapped text and blockquoted text. For example, with a PR body hard-wrapped at 80 (not an unusual editor setting), wrapping is skewed when viewing PRs as the body is indented. Block quoted text is similarly affected, when wrapped at 80, things get skewed, e.g. see comments on `gh issue view -R cli/cli -c 359` Fix by overriding the glamour default with a custom default of 120, which is the same default set by the glow cli markdown renderer. While this does not solve all problems, IMO it is a significant improvement. Fixes cli#3501 Possible improvement: wrap at terminal width if less than 120
mislav
left a comment
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.
Thanks for the suggestion!
Would it be possible to adjust the wrap setting to available terminal width, with some maximum setting hardcoded to prevent overly long lines?
Check the terminal width when setting the default word wrap limit for rendering markdown, and if term width lt default/120, set to term width. This is pretty hacky, I am not a golang programmer, not by a long shot!
|
@mislav Yes, it is possible to check the terminal width and take that into account when setting the wrap limit. I've added a (very hacky) commit that does that, but I'm sure this could be massively improved by someone who knows what they are doing (I've no experience with golang, I'm just making stuff work, like a complete novice). For now, I've left the default limit at 120, as this seems as reasonable default to make text readable (it is the default in Glow too). It works reasonably well, but not perfect for all blockquoted text in issue comments etc. as these are hard-wrapped already when received from the GH API and I'm not sure what that wrap limit is (looks like it might be 140). |
|
btw, most of that code is copied from Glow, see https://github.com/charmbracelet/glow/blob/e0789536674a25eeced8a12bd2fa17a1b6ef01a1/main.go#L156-L173 I think ideally it would use |
|
I can take a stab at making it work. |
|
FYI test failures are due to string equality assertions on output that was previously wrapped at 80, now 120. This can easily be fixed by just updating the assertions, but a better fix might be to allow the wrap width to be set to 80 for tests. If the |
|
I poked at this some. I think the best approach is to:
What do you think, @samcoe ? |
|
@vilmibm I think that there are only 9 call sites to |
|
@samcoe While that will fix the rendering issues associated hard-wrapping (for people with terminal cols wide enough, presumably most people), and would be a welcome change, for many people it will also result in very long lines of text that are hard to read (e.g. I think the suggestion of taking the terminal width into account, but having some maximum to prevent overly long lines would be preferred. What about adding a |
|
Oh, actually, maybe a better idea would be to make the wrap width a function of |
|
@mmrwoods I think the best/simplest solution here would be for |
|
@samcoe makes sense, and solves both problems 👍 |
samcoe
left a comment
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 went ahead and made the changes I suggested. Thanks for the contribution @mmrwoods.
The default word wrap limit in Glamour is 80, see
charmbracelet/glamour#161
This causes problems rendering hard-wrapped text and blockquoted text.
For example, with a PR body hard-wrapped at 80 (not an unusual editor
setting), wrapping is skewed when viewing PRs as the body is indented.
Block quoted text is similarly affected, when wrapped at 80, things
get skewed, e.g. see comments on
gh issue view -R cli/cli -c 359Fix by overriding the glamour default with a custom default of 120,
which is the same default set by the glow cli markdown renderer. While
this does not solve all problems, IMO it is a significant improvement.
Fixes #3501
Possible improvement: wrap at terminal width if less than 120