-
Notifications
You must be signed in to change notification settings - Fork 4
/
highlightjs-highlight-lines.min.js
1 lines (1 loc) · 1.63 KB
/
highlightjs-highlight-lines.min.js
1
!function(e,t){"use strict";e.hljs&&(e.hljs.highlightLinesAll=function(e){for(var t=0;t<e.length;++t)for(var n of e[t])--n.start,--n.end;i(e)},e.hljs.highlightLinesElement=function(e,t,n){for(var i of t)--i.start,--i.end;s(e,t,n)},e.hljs.initHighlightLinesOnLoad=function(e){n||(console.log("hljs.initHighlightLinesOnLoad is deprecated. Please use hljs.highlightLinesAll"),n=!0);i(e)},e.hljs.highlightLinesCode=function(e,t,n){l||(console.log("hljs.highlightLinesCode is deprecated. Please use hljs.highlightLinesElement"),l=!0);s(e,t,n)});var n=!1;function i(n){function i(){for(var e=t.getElementsByClassName("hljs"),i=0;i<e.length;++i)s(e[i],n[i])}"loading"!==t.readyState?i():e.addEventListener("DOMContentLoaded",function(){i()})}var l=!1;function s(e,t,n){function i(){if(e.innerHTML=e.innerHTML.replace(/([ \S]*\n|[ \S]*$)/gm,function(e){return'<div class="highlight-line">'+e+"</div>"}),void 0!==t){var n=parseInt(window.getComputedStyle(e).paddingLeft),i=parseInt(window.getComputedStyle(e).paddingRight),l=e.getElementsByClassName("highlight-line"),s=e.scrollWidth;for(var o of t)for(var r=o.start;r<=o.end;++r)l[r].style.backgroundColor=o.color,l[r].style.minWidth=s-n-i+"px"}}if(hljs.hasOwnProperty("initLineNumbersOnLoad")&&!1!==n)var l=100,s=setInterval(function(){var n=e.getElementsByTagName("table");if(0!=n.length){clearInterval(s);var o=n[0];o.style.width="100%";var r=o.getElementsByClassName("hljs-ln-numbers");for(var a of r)a.style.width="2em";if(void 0!==t){var h=e.getElementsByTagName("tr");for(var g of t)for(var d=g.start;d<=g.end;++d)h[d].style.backgroundColor=g.color}}else l--<0&&(clearInterval(s),i())},100);else i()}}(window,document);