Skip to content

Commit

Permalink
Fix removing line-numbers class form code. It removes space between o…
Browse files Browse the repository at this point in the history
…ther classes in code.
  • Loading branch information
dfitiskin committed Aug 13, 2016
1 parent 1cd81ff commit 8ddcc96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion plugins/line-numbers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ <h2>HTML</h2>
<p>Please note the <code>data-start="-5"</code> in the code below.</p>
<pre class="line-numbers" data-src="plugins/line-numbers/index.html" data-start="-5"></pre>

<h2>Inline HTML unescaped</h2>
<p>Please note the <code>data-start="10"</code> in the code below.</p>
<script class="language-markup language-html line-numbers other-class" type="text/plain" data-start="10">
<h2>HTML</h2>
<p>Please note the <code>data-start="-5"</code> in the code below.</p>
<pre class="line-numbers" data-src="plugins/line-numbers/index.html" data-start="-5"></pre>
</script>

<h2>Unknown languages</h2>
<pre class="language-none line-numbers"><code>This raw text
is not highlighted
Expand All @@ -55,10 +63,12 @@ <h2>Unknown languages</h2>

<script src="prism.js"></script>
<script src="plugins/line-numbers/prism-line-numbers.js"></script>
<script src="plugins/normalize-whitespace/prism-normalize-whitespace.js"></script>
<script src="plugins/unescaped-markup/prism-unescaped-markup.js"></script>
<script src="utopia.js"></script>
<script src="components.js"></script>
<script src="code.js"></script>


</body>
</html>
</html>
4 changes: 2 additions & 2 deletions plugins/line-numbers/prism-line-numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Prism.hooks.add('complete', function (env) {

if (clsReg.test(env.element.className)) {
// Remove the class "line-numbers" from the <code>
env.element.className = env.element.className.replace(clsReg, '');
env.element.className = env.element.className.replace(clsReg, ' ');
}
if (!clsReg.test(pre.className)) {
// Add the class "line-numbers" to the <pre>
Expand All @@ -54,4 +54,4 @@ Prism.hooks.add('complete', function (env) {

});

}());
}());

0 comments on commit 8ddcc96

Please sign in to comment.