cli / cli

GitHub’s official command line tool
https://cli.github.com
MIT License
36.72k stars 5.63k forks source link

max width of markdown is hardcoded, should be configurable #9627

Open smemsh opened 2 days ago

smemsh commented 2 days ago

Description

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.

norbertosus commented 2 days ago

packages/eslint-plugin/src/configs/recommended.ts

andyfeller commented 18 hours ago

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.

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 $GHMDWIDTH. 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.

Questions

  1. How many commands rendering markdown are in scope?

    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
  2. Is this contained to gh or to any extension using cli/go-gh?

  3. 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.