Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I view the source of Markdown files on Github?

Github helpfully renders Markdown (.md) files to HTML when viewing on github.com (for example, this README.md).

When viewing any other source file, it is shown as unrendered source code (for example, this .gitignore). A handy feature this gives is linking directly to a line in the source by clicking the line number (for example, like this).

How can I view the unrendered source of Markdown files on Github (so I can link to a particular line in the source)?

note: I know of the "Raw" button, however it does not provide any of the nice UI Github has.

like image 449
Jess Telford Avatar asked Nov 18 '14 02:11

Jess Telford


People also ask

How do I view RAW files on GitHub?

Viewing or copying the raw file contentOn GitHub.com, navigate to the main page of the repository. Click the file that you want to view. In the upper-right corner of the file view, click Raw.

How do I show Markdown in GitHub?

Just alt-tab between your editor and browser, and it will automatically re-render the markdown, and it looks exactly like it does on GitHub.

How do I view Markdown files in my browser?

To do that, right-click the extension icon in the in the toolbar and then select Manage Extensions. Scroll down until you see Allow Access to File URLs and toggle the switch to the On position. Now that Markdown Preview Plus is fully set up, you can drag any Markdown-formatted file into the browser to preview it.


2 Answers

If you don't want to use the "raw" button, you can (since June 2021) add ?plain=1 to your GitHub markdown file URL:

Appending ?plain=1 to the url for any Markdown file will now display the file without rendering.

As with other code files, it will also show line numbers, and can be used to link other users to a specific line or lines.
For example, appending ?plain=1#L52 will highlight line 52 of a plain text Markdown file.

Example:

https://github.com/git/git/blob/master/README.md?plain=1#L49-L51


Since Sept. 2021, there is a button which adds the ?plain=1 for you:

plain

like image 159
VonC Avatar answered Sep 21 '22 09:09

VonC


Use the "Raw" button. For instance, if you were looking at README.md there is a Raw button in the Navigation. This can be simple URL change (from blob to raw), but in this case becomes a separate link.

Edit: There is no "pretty" view for the Markdown source. There's the converted HTML view, the Raw view without the UI, and the Blame view. Only the Blame view provides you with the ability to link to a specific line within the source.

Edit 2: The other option is to use Anchors within the README.md. If you take the Installation title for example, you can directly link within the content of the Markdown file. Assuming you don't have anything hidden within the Markdown itself, this is closer still to solving your original question.

like image 29
CerealBoy Avatar answered Sep 19 '22 09:09

CerealBoy