Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@smemsh
Copy link
Contributor

@smemsh smemsh commented Sep 16, 2024

The markdown output width seems too wide. For example for gh pr view, it would be desirable to limit to 80 columns. This makes it more readable for some users that have a preference for narrower paragraphs.

In #6016 the maxwidth was changed from 80 to 120. The current code appears to use TerminalWidth() (pkg/iostreams/iostreams.go) which populates from termios (ie TIOCGWINSZ), but won't exceed the hardcoded value of 120 as set in WithWrap() (pkg/markdown/markdown.go).

This patch adds an environment variable override, $GH_MDWIDTH, similar to how $MANWIDTH is used to set the display width of man pages. The default remains at 120.

Without the patch, my workaround is like so:

script -qc "sh -c 'stty columns 80; gh pr view 1234'" /dev/null

It seems like the tool should have its own setting rather than hardcode it. The other option would be to use a gh config setting, but the env var is really simple and obvious, and has precedent with other tools (like man).

Please apply, thanks.

Fixes #9627

@smemsh smemsh requested a review from a team as a code owner September 16, 2024 06:10
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Sep 16, 2024
@williammartin
Copy link
Member

Hey @smemsh, I think this generally makes sense to me but can you create an issue to track this and as a place for us to iron out the details? We ask for this in our contributing guidelines just so that we have an artifact separate from the code change about higher level design input. Cheers!

@smemsh
Copy link
Contributor Author

smemsh commented Sep 16, 2024

@williammartin Apologies, figured it was too trivial to write a separate issue, didn't realize that was part of the workflow. Noted and done in #9627.

@smemsh smemsh force-pushed the markdown-maxwidth-env branch from 3426c7e to 394265f Compare September 16, 2024 13:16
@smemsh
Copy link
Contributor Author

smemsh commented Sep 16, 2024

added help text for the new env var to pkg/cmd/root/help_topic.go

@smemsh smemsh force-pushed the markdown-maxwidth-env branch from 394265f to 4aff4eb Compare October 5, 2024 00:43
Copy link
Contributor

@jtmcg jtmcg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the contribution

@jtmcg jtmcg enabled auto-merge October 7, 2024 19:32
@jtmcg jtmcg merged commit dfddb16 into cli:trunk Oct 7, 2024
@smemsh smemsh deleted the markdown-maxwidth-env branch October 17, 2024 03:26
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Oct 17, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.58.0` -> `v2.59.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.59.0`](https://github.com/cli/cli/releases/tag/v2.59.0): GitHub CLI 2.59.0

[Compare Source](cli/cli@v2.58.0...v2.59.0)

#### What's Changed

-   Allow community submitted design work by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9683
-   Improve `SECURITY.md` with expectations for privately reported vulnerabilities by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9687
-   Emit a log message when extension installation falls back to a `darwin-amd64` binary on an Apple Silicon macOS device by [@&#8203;timrogers](https://github.com/timrogers) in cli/cli#9650
-   Print the login URL even when opening a browser by [@&#8203;ulfjack](https://github.com/ulfjack) in cli/cli#7091
-   configurable maxwidth for markdown WithWrap() by [@&#8203;smemsh](https://github.com/smemsh) in cli/cli#9626
-   Handle errors when parsing hostname in auth flow by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9729
-   Add `repo license list/view` and `repo gitignore list/view` by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9721
-   Introduce testscript acceptance tests generally, and for the MR command specifically by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9745
-   Support `GH_ACCEPTANCE_SCRIPT` env var to target a single script by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9756
-   Ensure Acceptance defer failures are debuggable by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9754
-   Add acceptance task to makefile by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9748
-   Add Acceptance tests for `issue` command by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9757
-   Update IsEnterprise and IsTenancy for orthogonality using go-gh by [@&#8203;jtmcg](https://github.com/jtmcg) in cli/cli#9755
-   Supporting filtering on `gist list` by [@&#8203;heaths](https://github.com/heaths) in cli/cli#9728

#### New Contributors

-   [@&#8203;ulfjack](https://github.com/ulfjack) made their first contribution in cli/cli#7091
-   [@&#8203;smemsh](https://github.com/smemsh) made their first contribution in cli/cli#9626

**Full Changelog**: cli/cli@v2.58.0...v2.59.0

</details>

---

### Configuration

πŸ“… **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

β™» **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

πŸ”• **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

max width of markdown is hardcoded, should be configurable

4 participants