Skip to content

Instantly share code, notes, and snippets.

@ipconfiger
Last active December 17, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipconfiger/5607285 to your computer and use it in GitHub Desktop.
Save ipconfiger/5607285 to your computer and use it in GitHub Desktop.
replace a gist url to embed string
$.fn.extend({
gist:function(){
var r = /(https\:\/\/gist\.github\.com\/\w+\/\d+)/g;
this.each(function(index){
var content = $(this).html();
content = content.replace(r,"<script src=\"$1.js\"></script>");
$(this).html(content);
});
return true;
},
});
def embed_gist(text):
import re
p = re.compile(r"(https\:\/\/gist\.github\.com\/\w+\/\d+)")
return p.sub(r"<script src=\"\1.js\"></script>",text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment