Skip to content

Commit

Permalink
Unescaped markup plugin: Make it work with any language (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote authored Jan 17, 2018
1 parent 28e4b4c commit 7bcdae7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
8 changes: 4 additions & 4 deletions plugins/unescaped-markup/prism-unescaped-markup.css
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 2 additions & 6 deletions plugins/unescaped-markup/prism-unescaped-markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion plugins/unescaped-markup/prism-unescaped-markup.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7bcdae7

Please sign in to comment.