Commit 7bcdae72b76ef4486efac9e015938c3684c87937

Golmote 2018-01-17T23:32:41

Unescaped markup plugin: Make it work with any language (#1265)

diff --git a/plugins/unescaped-markup/prism-unescaped-markup.css b/plugins/unescaped-markup/prism-unescaped-markup.css
index 97c2608..3ba2a1e 100644
--- a/plugins/unescaped-markup/prism-unescaped-markup.css
+++ b/plugins/unescaped-markup/prism-unescaped-markup.css
@@ -1,8 +1,8 @@
 /* Fallback, in case JS does not run, to ensure the code is at least visible */
-.lang-markup script[type='text/plain'],
-.language-markup script[type='text/plain'],
-script[type='text/plain'].lang-markup,
-script[type='text/plain'].language-markup {
+[class*='lang-'] script[type='text/plain'],
+[class*='language-'] script[type='text/plain'],
+script[type='text/plain'][class*='lang-'],
+script[type='text/plain'][class*='language-'] {
 	display: block;
 	font: 100% Consolas, Monaco, monospace;
 	white-space: pre;
diff --git a/plugins/unescaped-markup/prism-unescaped-markup.js b/plugins/unescaped-markup/prism-unescaped-markup.js
index ad1eb63..64d2f64 100644
--- a/plugins/unescaped-markup/prism-unescaped-markup.js
+++ b/plugins/unescaped-markup/prism-unescaped-markup.js
@@ -7,15 +7,11 @@
 	Prism.plugins.UnescapedMarkup = true;
 
 	Prism.hooks.add('before-highlightall', function (env) {
-		env.selector += ", .lang-markup script[type='text/plain'], .language-markup script[type='text/plain']" +
-		                ", script[type='text/plain'].lang-markup, script[type='text/plain'].language-markup";
+		env.selector += ", [class*='lang-'] script[type='text/plain'], [class*='language-'] script[type='text/plain']" +
+		                ", script[type='text/plain'][class*='lang-'], script[type='text/plain'][class*='language-']";
 	});
 
 	Prism.hooks.add('before-sanity-check', function (env) {
-		if (env.language != "markup") {
-			return;
-		}
-
 		if (env.element.matches("script[type='text/plain']")) {
 			var code = document.createElement("code");
 			var pre = document.createElement("pre");
diff --git a/plugins/unescaped-markup/prism-unescaped-markup.min.js b/plugins/unescaped-markup/prism-unescaped-markup.min.js
index 9b28098..cb068cc 100644
--- a/plugins/unescaped-markup/prism-unescaped-markup.min.js
+++ b/plugins/unescaped-markup/prism-unescaped-markup.min.js
@@ -1 +1 @@
-!function(){"undefined"!=typeof self&&self.Prism&&self.document&&Prism.languages.markup&&(Prism.plugins.UnescapedMarkup=!0,Prism.hooks.add("before-highlightall",function(e){e.selector+=", .lang-markup script[type='text/plain'], .language-markup script[type='text/plain'], script[type='text/plain'].lang-markup, script[type='text/plain'].language-markup"}),Prism.hooks.add("before-sanity-check",function(e){if("markup"==e.language){if(e.element.matches("script[type='text/plain']")){var t=document.createElement("code"),a=document.createElement("pre");return a.className=t.className=e.element.className,e.element.dataset&&Object.keys(e.element.dataset).forEach(function(t){Object.prototype.hasOwnProperty.call(e.element.dataset,t)&&(a.dataset[t]=e.element.dataset[t])}),e.code=e.code.replace(/&lt;\/script(>|&gt;)/gi,"</script>"),t.textContent=e.code,a.appendChild(t),e.element.parentNode.replaceChild(a,e.element),e.element=t,void 0}var a=e.element.parentNode;!e.code&&a&&"pre"==a.nodeName.toLowerCase()&&e.element.childNodes.length&&"#comment"==e.element.childNodes[0].nodeName&&(e.element.textContent=e.code=e.element.childNodes[0].textContent)}}))}();
\ No newline at end of file
+!function(){"undefined"!=typeof self&&self.Prism&&self.document&&Prism.languages.markup&&(Prism.plugins.UnescapedMarkup=!0,Prism.hooks.add("before-highlightall",function(e){e.selector+=", [class*='lang-'] script[type='text/plain'], [class*='language-'] script[type='text/plain'], script[type='text/plain'][class*='lang-'], script[type='text/plain'][class*='language-']"}),Prism.hooks.add("before-sanity-check",function(e){if(e.element.matches("script[type='text/plain']")){var t=document.createElement("code"),n=document.createElement("pre");return n.className=t.className=e.element.className,e.element.dataset&&Object.keys(e.element.dataset).forEach(function(t){Object.prototype.hasOwnProperty.call(e.element.dataset,t)&&(n.dataset[t]=e.element.dataset[t])}),e.code=e.code.replace(/&lt;\/script(>|&gt;)/gi,"</script>"),t.textContent=e.code,n.appendChild(t),e.element.parentNode.replaceChild(n,e.element),e.element=t,void 0}var n=e.element.parentNode;!e.code&&n&&"pre"==n.nodeName.toLowerCase()&&e.element.childNodes.length&&"#comment"==e.element.childNodes[0].nodeName&&(e.element.textContent=e.code=e.element.childNodes[0].textContent)}))}();
\ No newline at end of file