Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a github permalink to a line in a markdown .md or .Rmd file?

Tags:

github

How can I create a permalink to specific lines in a .md or .Rmd file like README.md?

These files are rendered differently in github, so when I click on them I don't see the usual line-number editor where I can click on a line and ask it to give me the permalink to the selected lines, as described here.

like image 767
rmg Avatar asked Apr 04 '18 12:04

rmg


People also ask

How do I add a permalink to a line in Markdown?

To the left of the line or range of lines, click . In the drop-down menu, click Copy permalink . Navigate to the conversation where you want to link to the code snippet. Paste your permalink into a comment, and click Comment . You can link to specific lines in Markdown files by loading the Markdown file without Markdown rendering.

How do I create a permalink in a GitHub post?

Just view the file in GitHub, select the lines you want to create a permalink to, and then click on "..."->"Copy permalink" as shown below: Use a named destination anchor. They can be used as link targets inside the same HTML document or in other documents. above the line that you want as a destination for your link.

How do I commit a Markdown to GitHub?

Click "commit," add comment. Click the green arrow to push to GitHub. Go to GitHub, refresh the repository, and the markdown document with rendered code will be there When you knit, a new file will save to the Git window, called Title.docs

How do I push RMD files to GitHub?

Changing output to github_document makes the original .rmd knit to .md so the code can be rendered when pushed to Git. In the Git window, check the box to stage Title.md [NOT .rmd] Click "commit," add comment. Click the green arrow to push to GitHub.


1 Answers

Yes you can, link to specific lines in a Markdown file, by going to the Blame view of the file.

Click the Blame button

Then, press y to get a permalink to the version of the file that you see now. This will ensure the link persists if the file changes, is moved, renamed or deleted.

At this point, you can click a link, or Shift+click a range of lines, and the URL will update automatically.

Here is an example link.

like image 108
Dan Dascalescu Avatar answered Oct 23 '22 09:10

Dan Dascalescu