|
@@ -30,6 +30,7 @@ const Plugin = {
|
|
|
|
|
|
// Read the plugin config options and provide fallbacks
|
|
|
let config = reveal.getConfig().highlight || {};
|
|
|
+
|
|
|
config.highlightOnLoad = typeof config.highlightOnLoad === 'boolean' ? config.highlightOnLoad : true;
|
|
|
config.escapeHTML = typeof config.escapeHTML === 'boolean' ? config.escapeHTML : true;
|
|
|
|
|
@@ -61,12 +62,20 @@ const Plugin = {
|
|
|
hljs.highlightElement( event.currentTarget );
|
|
|
}, false );
|
|
|
|
|
|
- if( config.highlightOnLoad ) {
|
|
|
- Plugin.highlightBlock( block );
|
|
|
- }
|
|
|
-
|
|
|
} );
|
|
|
|
|
|
+ // Triggers a callback function before we trigger highlighting
|
|
|
+ if( typeof config.beforeHighlight === 'function' ) {
|
|
|
+ config.beforeHighlight( hljs );
|
|
|
+ }
|
|
|
+
|
|
|
+ // Run initial highlighting for all code
|
|
|
+ if( config.highlightOnLoad ) {
|
|
|
+ Array.from( reveal.getRevealElement().querySelectorAll( 'pre code' ) ).forEach( block => {
|
|
|
+ Plugin.highlightBlock( block );
|
|
|
+ } );
|
|
|
+ }
|
|
|
+
|
|
|
// If we're printing to PDF, scroll the code highlights of
|
|
|
// all blocks in the deck into view at once
|
|
|
reveal.on( 'pdf-ready', function() {
|