Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files that have a viewer in GitHub show up in the viewer instead of showing their lines of code #16

Open
synthead opened this issue Jul 28, 2023 · 0 comments · May be fixed by #17
Open

Comments

@synthead
Copy link

When viewing a markdown file, if I run :ToGithub, I get a URL like:

https://github.com/tonchis/vim-to-github/blob/9ea9c75b6cd48bd42823a39c56a05a2ff8161536/README.md#L3-L3

However, this link brings up the HTML representation of the markdown file, not the lines of code:

image

To always make the permalink open the lines of code, we want to add ?plain=1 to the URL, like so:

https://github.com/tonchis/vim-to-github/blob/9ea9c75b6cd48bd42823a39c56a05a2ff8161536/README.md?plain=1#L3-L3

This is the same as clicking the Code button without ?plain=1, and ?plain=1 also enables the "code" mode:

image

This also works well on files that don't have any "viewer" in github that would default to the "code" view. Plus, it's more explicit, which I think is a good thing. Here's an example:

https://github.com/tonchis/vim-to-github/blob/9ea9c75b6cd48bd42823a39c56a05a2ff8161536/plugin/to-github.vim?plain=1#L46-L49

And here's the link directly placed in the issue, where you can still see that the snippet is displayed:

function! s:run(...)
let command = join(a:000, ' | ')
return substitute(system(command), "\n", '', '')
endfunction

We should add ?plain=1 for all generated links! This will make the links always go to lines of code, no matter what 👌

@synthead synthead linked a pull request Jul 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant