Created
January 12, 2012 22:46
-
-
Save sgharms/1603633 to your computer and use it in GitHub Desktop.
Add line numbers to your GitHub gists from within Markdown within a WordPress installation
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
<script type="text/javascript"> | |
/* | |
* Add this to the top of your post. This will get interpreted in and applies to your page | |
* e.g. | |
* | |
* (this code) | |
* | |
* # My Summer Vacation | |
* | |
* ## Grandma's House | |
* | |
* We left for Grandma's house at 2pm on Friday. I was so excited to see her pet Bear and Fox! | |
*/ | |
var fixGistRules = [ | |
".gist .gist-highlight { border-left: 3ex solid #eee; position: relative;}", | |
".gist .gist-highlight pre { counter-reset: linenumbers;}", | |
".gist .gist-highlight pre div:before { color: #aaa; content: counter(linenumbers); counter-increment: linenumbers; left: -3ex; position: absolute; text-align: right; width: 2.5ex;}" ]; | |
var head = document.getElementsByTagName('head')[0], | |
style = document.createElement('style'); | |
rules = new Array(); | |
var i=0; | |
for ( i=0; i< fixGistRules.length; i++ ){ | |
var fullrule = document.createTextNode(fixGistRules[i]); | |
rules.push(fullrule); | |
} | |
style.type = 'text/css'; | |
for ( var i=0; i< rules.length; i++ ){ | |
if(style.styleSheet){ | |
style.styleSheet.cssText = rules[i].nodeValue; | |
}else { | |
style.appendChild(rules[i]); | |
head.appendChild(style); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment