Skip to content

[gh config] Inconsistent formatting of GitHub CLI manual entry #10348

Closed

Description

@iamazeem

Describe the bug

Apparently, when there's pipe sign | in the test, the formatting in the manual becomes inconsistent.
Looks like it's being rendered as a Markdown table.

See the screenshot for gh config below:

Image

The relevant output of gh config --help command:

$ gh config --help
Display or change configuration settings for gh.

Current respected settings:
- `git_protocol`: the protocol to use for git clone and push operations {https|ssh} (default https)
- `editor`: the text editor program to use for authoring text
- `prompt`: toggle interactive prompting in the terminal {enabled|disabled} (default enabled)
- `prefer_editor_prompt`: toggle preference for editor-based interactive prompting in the terminal {enabled|disabled} (default disabled)
- `pager`: the terminal pager program to send standard output to
- `http_unix_socket`: the path to a Unix socket through which to make an HTTP connection
- `browser`: the web browser to use for opening URLs
...

Affected settings are:

  • git_protocol
  • prompt
  • prefer_editor_prompt

Relevant code line where the allowed values are joined with |:

longDoc.WriteString(fmt.Sprintf(" {%s}", strings.Join(co.AllowedValues, "|")))

Affected version

$ gh version
gh version 2.66.0 (2025-01-30)
https://github.com/cli/cli/releases/tag/v2.66.0

Steps to reproduce the behavior

See https://cli.github.com/manual/gh_config.

Expected vs actual behavior

The formatting in the manual should be consistent.

Logs

N/A

Activity

  1. andyfeller commented on Jan 31, 2025

    @andyfeller
    Contributor

    Thank you for opening up this issue, @iamazeem! 🙇 I'm unsure if the problem is the markdown used or if this is an issue with underlying jekyll / pages / gems used to render the website markdown content. 🤔

    Source behind gh config on GitHub CLI manual

    ---
    layout: manual
    permalink: /:path/:basename
    ---
    
    {% raw %}## gh config
    
    Display or change configuration settings for gh.
    
    Current respected settings:
    - `git_protocol`: the protocol to use for git clone and push operations {https|ssh} (default https)
    - `editor`: the text editor program to use for authoring text
    - `prompt`: toggle interactive prompting in the terminal {enabled|disabled} (default enabled)
    - `prefer_editor_prompt`: toggle preference for editor-based interactive prompting in the terminal {enabled|disabled} (default disabled)
    - `pager`: the terminal pager program to send standard output to
    - `http_unix_socket`: the path to a Unix socket through which to make an HTTP connection
    - `browser`: the web browser to use for opening URLs
    
    
    ### Available commands
    
    * [gh config clear-cache](./gh_config_clear-cache)
    * [gh config get](./gh_config_get)
    * [gh config list](./gh_config_list)
    * [gh config set](./gh_config_set)
    
    
    {% endraw %}
    ### See also
    
    * [gh](./gh)

    Follow up

    Doing some digging, I'm wondering if this is a problem with the version of kramdown being used with our GitHub Pages site as this has been a historical problem:

    So, maybe we need to escape these pipes in a particular way for the website generation or maybe there's something we do on the kramdown side. 🤔

  2. added
    coreThis issue is not accepting PRs from outside contributors
    on Jan 31, 2025
  3. iamazeem commented on Feb 1, 2025

    @iamazeem
    ContributorAuthor

    Verified with kramdown (2.5.1) and it's indeed an issue.

    tl;dr (solution)

    Escaping | works i.e. \| (may need to escape slash as well i.e. \\| depending on the context).
    Replacing with HTML code works too i.e. use | instead.


    Details

    Tested with irb.
    Posting here with one line item for brevity.

    Issue

    > item = '- `git_protocol`: the protocol to use for git clone and push operations {https|ssh} (default https)'
     => "- `git_protocol`: the protocol to use for git clone and push operations {https|ssh} (default https)" 
    
    > print Kramdown::Document.new(item).to_html
    <ul>
      <li>
        <table>
          <tbody>
            <tr>
              <td><code>git_protocol</code>: the protocol to use for git clone and push operations {https</td>
              <td>ssh} (default https)</td>
            </tr>
          </tbody>
        </table>
      </li>
    </ul>
     => nil 

    Here the table is being generated in an unordered list and the item has been divided into two cells:

    <td><code>git_protocol</code>: the protocol to use for git clone and push operations {https</td>
    <td>ssh} (default https)</td>

    Solution

    With escaped |:

    > item = '- `git_protocol`: the protocol to use for git clone and push operations {https|ssh} (default https)'
     => "- `git_protocol`: the protocol to use for git clone and push operations {https|ssh} (default https)" 
    
    > item_with_escaped_pipe = item.sub('|', '\|')
     => "- `git_protocol`: the protocol to use for git clone and push operations {https\\|ssh} (default https)" 
    
    > print Kramdown::Document.new(item_with_escaped_pipe).to_html
    <ul>
      <li><code>git_protocol</code>: the protocol to use for git clone and push operations {https|ssh} (default https)</li>
    </ul>
     => nil 

    With HTML code &#124;:

    > item = '- `git_protocol`: the protocol to use for git clone and push operations {https|ssh} (default https)'
     => "- `git_protocol`: the protocol to use for git clone and push operations {https|ssh} (default https)" 
    
    > item_with_html_code = item.sub('|', '&#124;')
     => "- `git_protocol`: the protocol to use for git clone and push operations {https&#124;ssh} (default https)" 
    
    > print Kramdown::Document.new(item_with_html_code).to_html
    <ul>
      <li><code>git_protocol</code>: the protocol to use for git clone and push operations {https|ssh} (default https)</li>
    </ul>
     => nil
  4. added
    priority-3Affects a small number of users or is largely cosmetic
    and removed
    coreThis issue is not accepting PRs from outside contributors
    on Feb 3, 2025
  5. andyfeller commented on Feb 4, 2025

    @andyfeller
    Contributor

    Acceptance Criteria

    When GitHub CLI homepage docs are generated
    Then GitHub CLI manual pages containing pipes are escaped

    The following commands can be used to generate docs and find files containing pipes:

    go run ./cmd/gen-docs --website --doc-path site/manual
    find site/manual -name "*.md" -exec grep -rn '|' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocshelp wantedContributions welcomepriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions