aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2019-03-11 15:48:03 +0100
committerHakim El Hattab <hakim.elhattab@gmail.com>2019-03-11 15:48:03 +0100
commit8690858b6f314fe56942dc2cdd9cc6984f43b830 (patch)
treee2cac3fbc494516f3f5899df2fa06af7a281c60c /plugin
parent5adc2032c0d9d49a8b784d4a4f271999ad7e63a9 (diff)
downloadperl-software-in-gnu-guix-8690858b6f314fe56942dc2cdd9cc6984f43b830.tar
perl-software-in-gnu-guix-8690858b6f314fe56942dc2cdd9cc6984f43b830.tar.gz
more succinct syntax for code block line highlights
Diffstat (limited to 'plugin')
-rw-r--r--plugin/highlight/highlight.js19
1 files changed, 5 insertions, 14 deletions
diff --git a/plugin/highlight/highlight.js b/plugin/highlight/highlight.js
index 0c0ce5d..49ef64b 100644
--- a/plugin/highlight/highlight.js
+++ b/plugin/highlight/highlight.js
@@ -90,14 +90,12 @@ var RevealHighlight = (function() {
hljs.highlightBlock( block );
- if( block.classList.contains( 'line-numbers' ) ) {
+ if( block.hasAttribute( 'data-line-numbers' ) ) {
hljs.lineNumbersBlock( block );
- if( block.hasAttribute( 'data-highlight-lines' ) ) {
- // hljs.lineNumbersBlock runs async code on the next cycle,
- // so we need to do the same to execute after it's done
- setTimeout( RevealHighlight.highlightLines.bind( this, block ), 0 )
- }
+ // hljs.lineNumbersBlock runs async code on the next cycle,
+ // so we need to do the same to execute after it's done
+ setTimeout( RevealHighlight.highlightLines.bind( this, block ), 0 )
}
},
@@ -115,12 +113,10 @@ var RevealHighlight = (function() {
*/
highlightLines: function( block, linesToHighlight ) {
- linesToHighlight = linesToHighlight || block.getAttribute( 'data-highlight-lines' );
+ linesToHighlight = linesToHighlight || block.getAttribute( 'data-line-numbers' );
if( typeof linesToHighlight === 'string' ) {
- block.classList.add( 'highlight-lines' );
-
linesToHighlight.split( ',' ).forEach( function( lineNumbers ) {
lineNumbers = lineNumbers.split( '-' )
@@ -135,11 +131,6 @@ var RevealHighlight = (function() {
} );
}
- else {
-
- block.classList.remove( 'highlight-lines' );
-
- }
}
}