You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
max width of markdown is hardcoded, should be configurable #9627
The maximum width of Markdown renders on the terminal (example: gh pr view output) is currently the lower of the actual terminal width or 120. It should have a configurable maximum rather than being hardcoded, for those of us that prefer narrower paragraphs.
Proposed solution
Suggest to check an environment variable for override of the 120 hardcode. If not present, the existing default 120 will be used. Alternative idea would be a gh config variable.
Environment variable is my preference as it's easy to put in one's shell profile, standard method for many terminal apps, and configures any system without having to run a config command on each one (the usual deposit of shell profile would happen anyways). An example of analogous variable is $MANWIDTH.
Suggested variable name is $GH_MDWIDTH. The GH_ prefix appears to be used by a few other environment variables already.
Additional context
A patch is proposed already at #9626. The previous hardcode of 80 was raised to 120 in #6016.
Environment variable is my preference as it's easy to put in one's shell profile, standard method for many terminal apps, and configures any system without having to run a config command on each one (the usual deposit of shell profile would happen anyways). An example of analogous variable is $MANWIDTH.
Suggested variable name is $GH_MDWIDTH. The GH_ prefix appears to be used by a few other environment variables already.
I agree if we adopted this we'd want to give users the ability to set it via env var or gh config, also that we prefer prefixing our env vars to avoid conflicting with others.
All of the following commands render Markdown in different ways:
gh gist view
gh issue view
gh issue view --comments
gh pr create
gh pr review
gh pr view
gh pr view --comments
gh project view
gh reference
gh release view
gh repo view
gh workflow view
Is this contained to gh or to any extension using cli/go-gh?
Does this need to account for offset rendering?
Some of the commands above specify without indentation, however there are places where content is wrapped but it is indented.
For example, gh issue view https://github.com/cli/cli/issues/9627 --comments will render the issue body as well as the comments, which are wrapped by text width and indented.
It becomes less controversial when it's only opt-in, user-settable, and we don't change the existing default.
lines longer than 80 characters have been considered as inaccessible by W3C
(If only that applied to source code lines! 😉)
How many commands rendering markdown are in scope? All of the following commands render Markdown in different ways
It would be all callers of markdown.Render() that pass markdown.WithWrap(), which is where my proposed patch applies. Your list is correct, but they don't render differently that I can tell, they all pass markdown.WithWrap() and all pass terminal width, except workflow/view/view.go is passing 0 as the wrap width, which means "don't wrap at all," because that use case probably knows better. Likewise root/help_reference.go passes terminal width if a tty, else wrap 0. And I don't think --comments variants render any differently, they just show all rather than only the last comment.
(Aside: none of the commands wrap anyways if output isn't a terminal -- for example, is a pager -- which is really a bug, it should only consider whether stdin is a tty, not stdout. But that would be a separate issue.)
Terminals are already of variable width, and some people do still use 80 column terminals (perhaps tiling them). Those people will get the 80 column behavior without any changes, so they already encounter whatever issues that width would have. This proposal is only for people that want to set an upper limit, despite their terminal width.
Does this need to account for offset rendering? Some of the commands above specify without indentation, however there are places where content is wrapped but it is indented.
It seems to already work correctly, for example if I set width 40 then all the right margins align the same, including comments and accounting for indent. There's a couple stray miswraps like this (shown here with 60):
│ Environment variable is my preference as it's easy to
│ put in one's shell profile, standard method for many
│ terminal apps, and configures any system without
having
│ to run a config command on each one (the usual deposit
│ of shell profile would happen anyways). An example of
│ analogous variable is $MANWIDTH.Suggested variable
name
│ is $GH_MDWIDTH. The GH_ prefix appears to be used by a
│ few other environment variables already.
but those already exist, I see one with it set to 80, and also at 120 (ie without changing anything), and none at 40, so there is probably a math error in there somewhere, or like you said somewhere not accounting for indentation. But it's already there, and I would consider it a separate issue. I don't think the patch as written introduces any new bugs, and is opt-in. It only allows to override a hardcode which is somewhat arbitrary.
Is this contained to gh or to any extension using cli/go-gh?
The former. I'm only proposing to change this particular user of ghMarkdown.WithWrap(), not within go-gh.
[use some naming based on the idea of columns rather than width]
Yeah, I did show the precedent of $MANWIDTH, but I'm indifferent to the naming and we can change it to anything that works. Personally I think "width" is more descriptive of what's going on. It's a terminal, so we already know that the addressing dimensions are lines and columns of character cells. That said, any naming scheme works for me!
Activity
andyfeller commentedon Sep 18, 2024
One of my favorite debatable topics, @smemsh! 😆 In all seriousness, line length or text width is a genuine concern especially as lines longer than 80 characters have been considered as inaccessible by W3C.
I agree if we adopted this we'd want to give users the ability to set it via env var or
gh config, also that we prefer prefixing our env vars to avoid conflicting with others.Questions
How many commands rendering markdown are in scope?
All of the following commands render Markdown in different ways:
gh gist viewgh issue viewgh issue view --commentsgh pr creategh pr reviewgh pr viewgh pr view --commentsgh project viewgh referencegh release viewgh repo viewgh workflow viewIs this contained to
ghor to any extension usingcli/go-gh?Does this need to account for offset rendering?
Some of the commands above specify without indentation, however there are places where content is wrapped but it is indented.
For example,
gh issue view https://github.com/cli/cli/issues/9627 --commentswill render the issue body as well as the comments, which are wrapped by text width and indented.andyfeller commentedon Sep 19, 2024
The only other thought I want to toss out is following more of the
$LINESand$COLUMNSconventions used by Bash,linesandcolsused bytermcap.My concern with width nomenclature is that it doesn't convey units where most terminals / shells / CLIs deal in terms of columns and lines.
smemsh commentedon Sep 20, 2024
It becomes less controversial when it's only opt-in, user-settable, and we don't change the existing default.
(If only that applied to source code lines! 😉)
It would be all callers of
markdown.Render()that passmarkdown.WithWrap(), which is where my proposed patch applies. Your list is correct, but they don't render differently that I can tell, they all passmarkdown.WithWrap()and all pass terminal width, exceptworkflow/view/view.gois passing0as the wrap width, which means "don't wrap at all," because that use case probably knows better. Likewiseroot/help_reference.gopasses terminal width if a tty, else wrap0. And I don't think--commentsvariants render any differently, they just show all rather than only the last comment.(Aside: none of the commands wrap anyways if output isn't a terminal -- for example, is a pager -- which is really a bug, it should only consider whether stdin is a tty, not stdout. But that would be a separate issue.)
Terminals are already of variable width, and some people do still use 80 column terminals (perhaps tiling them). Those people will get the 80 column behavior without any changes, so they already encounter whatever issues that width would have. This proposal is only for people that want to set an upper limit, despite their terminal width.
It seems to already work correctly, for example if I set width 40 then all the right margins align the same, including comments and accounting for indent. There's a couple stray miswraps like this (shown here with 60):
but those already exist, I see one with it set to 80, and also at 120 (ie without changing anything), and none at 40, so there is probably a math error in there somewhere, or like you said somewhere not accounting for indentation. But it's already there, and I would consider it a separate issue. I don't think the patch as written introduces any new bugs, and is opt-in. It only allows to override a hardcode which is somewhat arbitrary.
The former. I'm only proposing to change this particular user of
ghMarkdown.WithWrap(), not within go-gh.Yeah, I did show the precedent of
$MANWIDTH, but I'm indifferent to the naming and we can change it to anything that works. Personally I think "width" is more descriptive of what's going on. It's a terminal, so we already know that the addressing dimensions are lines and columns of character cells. That said, any naming scheme works for me!