Explorar el Código

Allow override of HTML escaping in code blocks

This way, authors can use HTML for special formatting.
Eric Weikl hace 11 años
padre
commit
88eb0af776
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  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 ) {