瀏覽代碼

Allow override of HTML escaping in code blocks

This way, authors can use HTML for special formatting.
Eric Weikl 11 年之前
父節點
當前提交
88eb0af776
共有 1 個文件被更改,包括 4 次插入2 次删除
  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 ) {