diff options
Diffstat (limited to 'plugin/highlight/plugin.js')
-rw-r--r-- | plugin/highlight/plugin.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plugin/highlight/plugin.js b/plugin/highlight/plugin.js index f6cc624..00a731b 100644 --- a/plugin/highlight/plugin.js +++ b/plugin/highlight/plugin.js @@ -35,6 +35,15 @@ const Plugin = { [].slice.call( reveal.getRevealElement().querySelectorAll( 'pre code' ) ).forEach( function( block ) { + // Code can optionally be wrapped in script template to avoid + // HTML being parsed by the browser (i.e. when you need to + // include <, > or & in your code). + let substitute = block.querySelector( 'script[type="text/template"]' ); + if( substitute ) { + // textContent handles the HTML entity escapes for us + block.textContent = substitute.innerHTML; + } + // Trim whitespace if the "data-trim" attribute is present if( block.hasAttribute( 'data-trim' ) && typeof block.innerHTML.trim === 'function' ) { block.innerHTML = betterTrim( block ); |