diff --git a/css/zerobin.css b/css/zerobin.css index 2bd230bb..f3d76815 100644 --- a/css/zerobin.css +++ b/css/zerobin.css @@ -365,4 +365,25 @@ pre a:hover { color:#64B9C6; } +/* +pre { + counter-reset: lines; +} + +pre .line { + counter-increment: lines; +} +pre .line::before { + content: counter(lines); text-align: right; + display: inline-block; width: 2em; + padding-right: 0.5em; margin-right: 0.5em; + color: #BBB; border-right: solid 1px; +} +*/ +pre ol { +list-style:decimal outside none; +} +pre ol li { +font-weight: normal; vertical-align:top; +} diff --git a/js/zerobin.js b/js/zerobin.js index a9b6c1d9..76b20de7 100644 --- a/js/zerobin.js +++ b/js/zerobin.js @@ -182,6 +182,13 @@ function applySyntaxColoring() $('div#cleartext').css('padding','0'); // Remove white padding around code box. } +function addLineNumbers() { + cleartext = $('div#cleartext > pre > code'); + newtext = cleartext.html() + .replace( /(\r?\n)/g, "$1
  • "); + newtext = "
    1. " + newtext + "
    "; + cleartext.html(newtext); +} /** * Show decrypted text in the display area, including discussion (if open) @@ -203,7 +210,10 @@ function displayMessages(key, comments) { // comments[0] is the paste itself. - if (comments[0].meta.syntaxcoloring) applySyntaxColoring(); + if (comments[0].meta.syntaxcoloring) { + applySyntaxColoring(); + addLineNumbers(); + } // Display paste expiration. if (comments[0].meta.expire_date) $('div#remainingtime').removeClass('foryoureyesonly').text('This document will expire in '+secondsToHuman(comments[0].meta.remaining_time)+'.').show();