0

In a markdown file in a Gist, how do you quote some lines of code that are in a GitHub project?

If I was writing a Gist to try and explain how something works, I might have a block of text, then quote some code. I don't want to cut and paste the code in, I just want to quote some lines of code in a GitHub project. I am sure I have seen this done, but can't find an explanation of how to do it.

For example:

This algorithm makes use of Dijkstra's topological sort algorithm:

100: Result myFancyPantsAlgorithm(Blah blah) {
101:    youGetTheIdea();
102: }
user2800708
  • 1,890
  • 2
  • 18
  • 31

1 Answers1

0

It is not possible to embed GitHub code snippets from Repositories.

What you might have seen is having a gist embedded in a "normal" website which is possible because GitHub provides a script to embed gists.

The script tag is (un)fortunately not whitelisted to be used in GitHub Flavored Markdown, so it is not possible to embed a gist in markdown.

A way to get around this would be to set a gh-page up, where you are able to embed a Gist as this SO-question shows. But then you're still not referencing to any live codebase.

So the answer to your question is: this is not possible, wether by embedding code from a repository nor by taking a detour via using gists.

Community
  • 1
  • 1
Florian Neumann
  • 5,587
  • 1
  • 39
  • 48