فهرست منبع

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 ) {