Moved my code to auto escape html to the right place
authorRaymond Camden <raymondcamden@gmail.com>
Wed, 1 May 2013 19:44:53 +0000 (14:44 -0500)
committerRaymond Camden <raymondcamden@gmail.com>
Wed, 1 May 2013 19:44:53 +0000 (14:44 -0500)
js/reveal.js
plugin/highlight/highlight.js

index f9590d5a3bcca7b405593c09f357e8746c756bcb..a4a71db49240dc5be52e95a39c91c4f64d318bda 100644 (file)
@@ -235,18 +235,6 @@ var Reveal = (function(){
                        dom.controlsNext = toArray( document.querySelectorAll( '.navigate-next' ) );
                }
 
-               //Auto scape code blocks
-               var cblocks = document.querySelectorAll("pre code");
-               
-               if(cblocks.length) {
-                       for(var i=0, len=cblocks.length; i<len; i++) {
-                               var thisDom = cblocks[i];
-                               var html = thisDom.innerHTML;
-                               html = html.replace(/</g,"&lt;").replace(/>/g,"&gt;");
-                               thisDom.innerHTML = html;
-                       }
-               }               
-
        }
 
        /**
index 67563591a83765cbd6e561f1347874bb51911a04..5a6ad903fd82236d4e17f6115f132d15450f6e70 100644 (file)
@@ -11,6 +11,9 @@
                                element.innerHTML = element.innerHTML.trim();
                        }
 
+                       // Now escape html
+                       element.innerHTML = element.innerHTML.replace(/</g,"&lt;").replace(/>/g,"&gt;");
+
                        // re-highlight when focus is lost (for edited code)
                        element.addEventListener( 'focusout', function( event ) {
                                hljs.highlightBlock( event.currentTarget );