Skip to content

unable to browse to line number if file is markdown #4307

@andrewhsu

Description

@andrewhsu

Describe the bug

Using gh to browse a file with given line number does not work with Markdown files. The URL the user is taken to is the rendered Markdown view without line numbers on the left-hand side.

Steps to reproduce the behavior

$ gh browse README.md:3
now opening https://github.com/cli/cli/tree/trunk/README.md#L3 in browser
$ gh --version
gh version 2.0.0 (2021-08-24)
https://github.com/cli/cli/releases/tag/v2.0.0

Expected vs actual behavior

Looks like a ?plain=1 parameter was added to GitHub Web UI to specifically help navigate to Markdown lines.

So, instead of:

I'd expect the user to be taken to:

note: the new URL has blob in the path because ?plain=1 does not work with tree in the path

Logs

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp 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