Skip to content

Instantly share code, notes, and snippets.

@scrooloose
Created June 27, 2010 08:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scrooloose/454771 to your computer and use it in GitHub Desktop.
Save scrooloose/454771 to your computer and use it in GitHub Desktop.
A hack to add line numbers to gists, requires jquery
function addLineNumbersToAllGists() {
$('.gist').each( function() {
_addLineNumbersToGist('#' + $(this).attr('id'));
});
}
function addLineNumbersToGist(id) {
_addLineNumbersToGist('#gist-' + id);
}
function _addLineNumbersToGist(css_selector) {
$(document).ready( function() {
$(css_selector + ' .line').each(function(i, e) {
$(this).prepend(
$('<div/>').css({
'float' : 'left',
'width': '30px',
'font-weight' : 'bold',
'color': '#808080'
}).text(++i)
);
});
});
}
@gaving
Copy link

gaving commented Jun 27, 2010

$('.line').each(function(i, e) {
    $(this).prepend(
        $('<div/>').css({
            'float' : 'left',
            'width': '30px',
            'font-weight' : 'bold',
            'color': 'grey'
        }).text(++i)
    );
});

maybe

@scrooloose
Copy link
Author

hey gaving!

Your hacks are far superior, but there is one really strange thing I've found with IE6: it doesnt like the 'color': 'grey' line.... if you use 'color': '#808080' (where #808080 == 'grey') then it works fine. OMG IE6 FTW

@gaving
Copy link

gaving commented Jun 28, 2010

Aaaah IE6, good times. Seems like it doesn't recognise the 'grey' keyword and only 'gray' or the hex. http://code.merlak.net/2010/04/grey-vs-gray-internet-explorer-css-color-difference/

@scrooloose
Copy link
Author

ah, thanks :) that article is hilarious, ie6 requires an "a" for gray, but also requires an "e" for lightgrey! wtf?! ultimate fail!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment