diff options
author | Brandon Mathis <brandon@imathis.com> | 2011-05-30 00:30:16 -0400 |
---|---|---|
committer | Brandon Mathis <brandon@imathis.com> | 2011-05-30 00:30:16 -0400 |
commit | 8698a276f937cb1cd6f67f7f213e2ea438500d7e (patch) | |
tree | 3963ed8f9750cd565087ce54fe8de38d9f5c606d /source/javascripts/syntax-helper.js | |
parent | c7d5365f81552cae16bbb91696ca3e67b4a0a2e9 (diff) | |
download | my_new_personal_website-8698a276f937cb1cd6f67f7f213e2ea438500d7e.tar.xz my_new_personal_website-8698a276f937cb1cd6f67f7f213e2ea438500d7e.zip |
Cleaned out public from repository, updated gitignore, added syntax
highlighting tests, improved syntax highlighting and styling of pre
blocks.
Overriding dynamic gist styling.
Added a plugin for pygments caching which should speed things up
terrifically.
added ender.js as a lightweight way of scripting the DOM, events, etc.
Some general typography and semantic html improvements.
Diffstat (limited to 'source/javascripts/syntax-helper.js')
-rw-r--r-- | source/javascripts/syntax-helper.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/javascripts/syntax-helper.js b/source/javascripts/syntax-helper.js new file mode 100644 index 00000000..e1a6889b --- /dev/null +++ b/source/javascripts/syntax-helper.js @@ -0,0 +1,30 @@ +function addDivLines(){ + $('div.highlight pre code').each(function(el){ + var content = bonzo(el).html(); + var lines = content.split('\n'); + var count = lines.length; + bonzo(lines).each(function(line, index){ + if(line == '') line = ' '; + lines[index] = '<div class="line">' + line + '</div>'; + }); + $(el).html(lines.join('')); + }); +} +function preToTable(){ + $('div.highlight').each(function(code){ + var tableStart = '<table cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter">'; + var lineNumbers = '<pre class="line-numbers">'; + var tableMiddle = '</pre></td><td class="code" width="100%">'; + var tableEnd = '</td></tr></tbody></table>'; + var count = $('div.line', code).length; + for (i=1;i<=count; i++){ + lineNumbers += '<span class="line">'+i+'</span>\n'; + } + table = tableStart + lineNumbers + tableMiddle + '<pre>'+$('pre', code).html()+'</pre>' + tableEnd; + $(code).html(table); + }); +} +$.domReady(function () { + addDivLines(); + preToTable(); +}); |