Created
March 2, 2010 08:24
-
-
Save phatduckk/319263 to your computer and use it in GitHub Desktop.
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
<link href="/pretty/prettify.css" media="all" rel="stylesheet" type="text/css" /> | |
<script src="/pretty/prettify.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script> | |
function zpad(num, padto) { | |
var asStr = "" + num; | |
var numDigits = padto - asStr.length; | |
var str = ""; | |
for (var i = 0; i < numDigits; i++) { | |
str += "0"; | |
} | |
return str + num; | |
} | |
$(document).ready(function() { | |
$("code").each(function(){ | |
var lines = $(this).html(); | |
var splitLines = lines.split("\n"); | |
var numLines = splitLines.length; | |
var strLines = "" + numLines; | |
var digits = strLines.length; | |
if (numLines > 1) { | |
var str = ""; | |
var showLine = 1; | |
for (var i = 0; i< numLines; i++) { | |
if (i == 0 && splitLines[i] == "") continue; | |
if (i == numLines - 1 && splitLines[i] == "") continue; | |
str += "<span class=\"nocode\">" + (zpad(showLine++, digits)) + "</span>" + splitLines[i] + "<br />"; | |
} | |
$(this).html("<pre class=\"prettyprint\">" + str + "</pre>"); | |
$(this).addClass("prettyprint"); | |
} | |
}) | |
prettyPrint(); | |
}) | |
</script> | |
/***** css additions ****/ | |
.nocode { | |
background-color: #ddd; | |
color: #777; | |
padding: 0 5px 0 5px; | |
margin-right: 10px; | |
} | |
.contextual { | |
float: none; | |
text-align: right; | |
} | |
div.wiki pre.prettyprint { | |
margin: 1em 0em 1em 0em; | |
width: auto; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment