Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I embed a single file from a GitHub gist with the new gist interface?

Tags:

github

gist

The new GitHub Gist interface has one embed snippet for the entire gist which embeds all files in the gist. The old interface had embed code for each file in the gist. Anyone know if there's a trick to embed a single file?

like image 565
Travis Reeder Avatar asked Jan 08 '13 00:01

Travis Reeder


People also ask

How do you embed a gist?

Embedding with a URL To quickly embed a Gist, simply copy the gist's URL from your web browser's address bar while viewing the gist. Paste it on a line by itself in your Visual editor. Make sure that it is not hyperlinked.

How do I add a link to my gist?

In your Gist workspace, navigate to knowledge base section. Hover over the knowledge base article where you want to add an anchor, then click Edit. Scroll down to the section of the article, where you want your link to jump to. Add an ID to the element, as shown (example: id="order-delivery-process" ).


1 Answers

Take the gist URL from the left-hand side and after the .js add a query string like ?file=myFile.blah, e.g.

<script src="https://gist.github.com/4505639.js?file=macroBuild.scala" type="text/javascript"></script> 
like image 101
Roland Kuhn Avatar answered Oct 11 '22 12:10

Roland Kuhn