Browse Source

Add line numbers for pastebin. Fixes #70

pull/73/head v1.1.6
andreimarcu 9 years ago
parent
commit
88c00027ea
  1. 13
      static/css/highlight/tomorrow.css
  2. 1
      static/js/bin_hljs.js
  3. 3
      static/js/highlight/highlightjs-line-numbers.min.js
  4. 1
      templates/display/bin.html

13
static/css/highlight/tomorrow.css

@ -79,6 +79,19 @@
padding: 0.5em; padding: 0.5em;
} }
.hljs-line-numbers {
text-align: right;
border-right: 1px solid #ccc;
margin-right: 5px;
color: #999;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.coffeescript .javascript, .coffeescript .javascript,
.javascript .xml, .javascript .xml,
.tex .hljs-formula, .tex .hljs-formula,

1
static/js/bin_hljs.js

@ -2,5 +2,6 @@
hljs.tabReplace = ' '; hljs.tabReplace = ' ';
hljs.initHighlightingOnLoad(); hljs.initHighlightingOnLoad();
hljs.initLineNumbersOnLoad();
// @license-end // @license-end

3
static/js/highlight/highlightjs-line-numbers.min.js

@ -0,0 +1,3 @@
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
!function(e){"use strict";function t(){e.addEventListener("load",function(){try{var e=document.querySelectorAll("code.hljs");for(var t in e)e.hasOwnProperty(t)&&n(e[t])}catch(r){console.error("LineNumbers error: ",r)}})}function n(e){if("object"==typeof e){var t=e.parentNode,n=r(t.textContent);if(n>1){for(var o="",l=0;n>l;l++)o+=l+1+"\n";var c=document.createElement("code");c.className="hljs hljs-line-numbers",c.style["float"]="left",c.textContent=o,t.insertBefore(c,e)}}}function r(e){if(0===e.length)return 0;var t=/\r\n|\r|\n/g,n=e.match(t);return n=n?n.length:0,e[e.length-1].match(t)||(n+=1),n}"undefined"==typeof e.hljs?console.error("highlight.js not detected!"):(e.hljs.initLineNumbersOnLoad=t,e.hljs.lineNumbersBlock=n)}(window);
// @license-end

1
templates/display/bin.html

@ -44,6 +44,7 @@
{% if extra.lang_hl != "text" %} {% if extra.lang_hl != "text" %}
<script src="{{ sitepath }}static/js/highlight/highlight.pack.js"></script> <script src="{{ sitepath }}static/js/highlight/highlight.pack.js"></script>
<script src="{{ sitepath }}static/js/highlight/highlightjs-line-numbers.min.js"></script>
<script src="{{ sitepath }}static/js/bin_hljs.js"></script> <script src="{{ sitepath }}static/js/bin_hljs.js"></script>
{% endif %} {% endif %}

Loading…
Cancel
Save