Last active
December 17, 2015 12:09
-
-
Save ipconfiger/5607285 to your computer and use it in GitHub Desktop.
replace a gist url to embed string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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; | |
}, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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