Skip to content

Commit 7bcdae7

Browse files
authored
Unescaped markup plugin: Make it work with any language (#1265)
1 parent 28e4b4c commit 7bcdae7

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

plugins/unescaped-markup/prism-unescaped-markup.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* Fallback, in case JS does not run, to ensure the code is at least visible */
2-
.lang-markup script[type='text/plain'],
3-
.language-markup script[type='text/plain'],
4-
script[type='text/plain'].lang-markup,
5-
script[type='text/plain'].language-markup {
2+
[class*='lang-'] script[type='text/plain'],
3+
[class*='language-'] script[type='text/plain'],
4+
script[type='text/plain'][class*='lang-'],
5+
script[type='text/plain'][class*='language-'] {
66
display: block;
77
font: 100% Consolas, Monaco, monospace;
88
white-space: pre;

plugins/unescaped-markup/prism-unescaped-markup.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77
Prism.plugins.UnescapedMarkup = true;
88

99
Prism.hooks.add('before-highlightall', function (env) {
10-
env.selector += ", .lang-markup script[type='text/plain'], .language-markup script[type='text/plain']" +
11-
", script[type='text/plain'].lang-markup, script[type='text/plain'].language-markup";
10+
env.selector += ", [class*='lang-'] script[type='text/plain'], [class*='language-'] script[type='text/plain']" +
11+
", script[type='text/plain'][class*='lang-'], script[type='text/plain'][class*='language-']";
1212
});
1313

1414
Prism.hooks.add('before-sanity-check', function (env) {
15-
if (env.language != "markup") {
16-
return;
17-
}
18-
1915
if (env.element.matches("script[type='text/plain']")) {
2016
var code = document.createElement("code");
2117
var pre = document.createElement("pre");

plugins/unescaped-markup/prism-unescaped-markup.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)