mirror of
https://github.com/hakimel/reveal.js.git
synced 2025-08-12 17:44:53 +02:00
add support for wrapping code in script tempalte to avoid html parser #2684
This commit is contained in:
@@ -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 );
|
||||
|
Reference in New Issue
Block a user