Browse Source

Allow override of HTML escaping in code blocks

This way, authors can use HTML for special formatting.
Eric Weikl 11 years ago
parent
commit
88eb0af776
1 changed files with 4 additions and 2 deletions
  1. 4 2
      plugin/highlight/highlight.js

+ 4 - 2
plugin/highlight/highlight.js

@@ -11,8 +11,10 @@
 				element.innerHTML = element.innerHTML.trim();
 			}
 
-			// Now escape html
-			element.innerHTML = element.innerHTML.replace(/</g,"&lt;").replace(/>/g,"&gt;");
+			// Now escape html unless prevented by author
+			if( ! element.hasAttribute( 'data-noescape' )) {
+				element.innerHTML = element.innerHTML.replace(/</g,"&lt;").replace(/>/g,"&gt;");
+			}
 
 			// re-highlight when focus is lost (for edited code)
 			element.addEventListener( 'focusout', function( event ) {