Browse Source

Get rid of highlightjs-line-numbers.js

pull/87/head
andreimarcu 9 years ago
parent
commit
0a361a268c
  1. 28
      static/css/highlight/lines.css
  2. 10
      static/js/bin_hljs.js
  3. 3
      static/js/highlight/highlightjs-line-numbers.min.js
  4. 2
      templates/display/bin.html

28
static/css/highlight/lines.css

@ -0,0 +1,28 @@
#normal-code {
border-left: 1px solid #ccc;
margin-left: 36px;
position: relative;
}
#normal-code code {
counter-reset: linenumbers;
}
#normal-code code div:before {
content: counter(linenumbers);
counter-increment: linenumbers;
left: -36px;
width: 28px;
position: absolute;
text-align: right;
padding-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;
}

10
static/js/bin_hljs.js

@ -2,6 +2,14 @@
hljs.tabReplace = ' ';
hljs.initHighlightingOnLoad();
hljs.initLineNumbersOnLoad();
var codeb = document.getElementById("codeb");
var lines = codeb.innerHTML.split("\n");
codeb.innerHTML = "";
for (var i = 0; i < lines.length; i++) {
var div = document.createElement("div");
div.innerHTML = lines[i] + "\n";
codeb.appendChild(div);
};
// @license-end

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

@ -1,3 +0,0 @@
// @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

2
templates/display/bin.html

@ -2,6 +2,7 @@
{% block head %}
<link href="{{ sitepath }}static/css/highlight/tomorrow.css" rel="stylesheet" type="text/css">
<link href="{{ sitepath }}static/css/highlight/lines.css" rel="stylesheet" type="text/css">
{% endblock %}
{% block innercontentmore %} class="scrollable"{% endblock %}
@ -44,7 +45,6 @@
{% if extra.lang_hl != "text" %}
<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>
{% endif %}

Loading…
Cancel
Save