18

It should be pretty straight forward to add the following code snippets to the allowed HTML subset, or some additional markup that would effectively do the same thing.

<script src="https://gist.github.com/839992.js?file=Switch.java"></script>

so that the above would display the nice formatted, line numbered, code folded display that GitHub provides inline as a code block.

2
  • 3
    I think this would be great for a few more reasons: - people are already posting links to github (this would allow more control and would show when it is well used)- allow sourcing of the raw code directly (no more copy pasting) - when the code gets updated (for example to allow compatibility to upgrades) the question get updated automaticly - you could probably still have a line limit -the solution may spread through the net faster - you could maybe get github to have a specific stack overflow tag/gist type -... Commented May 9, 2012 at 19:25
  • 1
    Not to mention how easy it would be to clone the code of the question, fiddle with it and push a fork to link to in the response. You could then even build upon other responders forks to improve existing answers. Commented Apr 21, 2015 at 19:30

1 Answer 1

2

This already happens in chat (paste it as a single link on a single message), but I don't think we need to support it here for two reasons

  1. The relevant bits of code should be in the post for context, otherwise the question / answer is incomplete.

  2. If you need to say "and there's 50kb more code to look at here", then a link suffices for that purpose.

2
  • 2
    Couldn't line limits still be imposed to the gist script? How to deal with frequent required update of answers du to changes in related structure, data, script...? Commented May 9, 2012 at 19:36
  • 1
    Sometimes a nicely formatted gist with around 10 lines could really do the trick, inline. How about a cutoff at around 10 lines? Commented Nov 6, 2015 at 11:15

You must log in to answer this question.