Suggestion - Any way to Link to code And line - kill all stale code in web tutorials


not sure if this is the place to post this but just a suggestion or feature request.

I was reading a tutorial and it had code in a zip which you could download for github and it had snippets of the code in the tutorial (in HTML).

Example of tutorial with code snippets

The tutorial was old but still worked but the the snippets were in older version of the language. 

The github had been updated but was now out of sync with the tutorial.

Is there any way to show the current code on the github repo but hosted in the web page of the tutorial.

I can add a link to the whole class e.g.

But theres no way to link to a line number

I know you can embed gists

What would be cool is a HTML view you could install on any web page.

Give it path to file

and start and end line numbers to show only a section of that file.


func toDictionary() -> NSDictionary

could be specified as 


lineStart: 37

lineEnd: 62

shows only 

func toDictionary() -> NSDictionary
let dictionary = NSMutableDictionary()

return dictionary

Advantages: when new sdks come out just recompile your code to keep it up to date

check the line numbers in case anything changed and change only them in your tutorial.

Hey there,

You can link to a specific line number in a file on GitHub in a few different ways, depending on your needs. The simplest way is to:

  1. Navigate to the file, ex:
  2. Left-click on the line number you want to highlight, ex: left-click on line 7
  3. Notice that the line you clicked is highlighted and the URL in your address bar has changed
  4. Copy the URL out of the address bar and use that to link to line 7 in

Now, if you want to link not only to line 7, but that specific version of line 7 no matter how that file changes in the future, you can:

  1. Follow the above steps
  2. Click the ellipsis menu to the left of the line number
  3. Click “Copy permalink”

This will copy the link to your clipboard that links to line 7 of that version of the file forever.

As far as embedding code in a non-GitHub web page, the best way to do that is through a Gist as you already understand.

I hope that helps!