瀏覽代碼

Allow users to register additional languages via callback

Asvin Goel 3 年之前
父節點
當前提交
ca9ce4b592
共有 3 個文件被更改,包括 7 次插入1 次删除
  1. 0 0
      plugin/highlight/highlight.esm.js
  2. 0 0
      plugin/highlight/highlight.js
  3. 7 1
      plugin/highlight/plugin.js

File diff suppressed because it is too large
+ 0 - 0
plugin/highlight/highlight.esm.js


File diff suppressed because it is too large
+ 0 - 0
plugin/highlight/highlight.js


+ 7 - 1
plugin/highlight/plugin.js

@@ -30,6 +30,7 @@ const Plugin = {
 
 		// Read the plugin config options and provide fallbacks
 		var config = reveal.getConfig().highlight || {};
+		config.callback = typeof config.callback === 'function' ? config.callback : null;
 		config.highlightOnLoad = typeof config.highlightOnLoad === 'boolean' ? config.highlightOnLoad : true;
 		config.escapeHTML = typeof config.escapeHTML === 'boolean' ? config.escapeHTML : true;
 
@@ -59,6 +60,11 @@ const Plugin = {
 				hljs.highlightBlock( event.currentTarget );
 			}, false );
 
+			// Allow users to register additional languages via callback
+			if ( config.callback ) {
+				config.callback( hljs );
+			}
+			
 			if( config.highlightOnLoad ) {
 				Plugin.highlightBlock( block );
 			}
@@ -87,7 +93,7 @@ const Plugin = {
 
 		hljs.highlightBlock( block );
 
-		// Don't generate line numbers for empty code blocks
+		// Don't generate line numbers for empty	 code blocks
 		if( block.innerHTML.trim().length === 0 ) return;
 
 		if( block.hasAttribute( 'data-line-numbers' ) ) {

Some files were not shown because too many files changed in this diff