Skip to content

Commit

Permalink
Apply changes from #754 to all plugins so that none of them throw err…
Browse files Browse the repository at this point in the history
…ors in node.

Autolinker, Show invisibles and WPD can now be used with node.
Removed unused minified CSS file.
Also added missing space between attributes during wrapping.
  • Loading branch information
Golmote committed Sep 3, 2015
1 parent c8f83b2 commit 0356c58
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 31 deletions.
2 changes: 1 addition & 1 deletion components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ Token.stringify = function(o, language, parent) {
var attributes = '';

for (var name in env.attributes) {
attributes += name + '="' + (env.attributes[name] || '') + '"';
attributes += (attributes ? ' ' : '') + name + '="' + (env.attributes[name] || '') + '"';
}

return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
Expand Down
2 changes: 1 addition & 1 deletion components/prism-core.min.js

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

5 changes: 4 additions & 1 deletion plugins/autolinker/prism-autolinker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(function(){

if (!self.Prism) {
if (
typeof self !== 'undefined' && !self.Prism ||
typeof global !== 'undefined' && !global.Prism
) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/autolinker/prism-autolinker.min.js

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

5 changes: 4 additions & 1 deletion plugins/highlight-keywords/prism-highlight-keywords.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(function(){

if (!self.Prism) {
if (
typeof self !== 'undefined' && !self.Prism ||
typeof global !== 'undefined' && !global.Prism
) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/highlight-keywords/prism-highlight-keywords.min.js

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

2 changes: 1 addition & 1 deletion plugins/line-highlight/prism-line-highlight.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(){

if(!window.Prism) {
if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/line-highlight/prism-line-highlight.min.js

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

14 changes: 11 additions & 3 deletions plugins/line-numbers/prism-line-numbers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
(function() {

if (typeof self === 'undefined' || !self.Prism || !self.document) {
return;
}

Prism.hooks.add('complete', function (env) {
if (!env.code) {
return;
Expand All @@ -8,13 +14,13 @@ Prism.hooks.add('complete', function (env) {
var clsReg = /\s*\bline-numbers\b\s*/;
if (
!pre || !/pre/i.test(pre.nodeName) ||
// Abort only if nor the <pre> nor the <code> have the class
// Abort only if nor the <pre> nor the <code> have the class
(!clsReg.test(pre.className) && !clsReg.test(env.element.className))
) {
return;
}

if ( env.element.querySelector(".line-numbers-rows") ) {
if (env.element.querySelector(".line-numbers-rows")) {
// Abort if line numbers already exists
return;
}
Expand Down Expand Up @@ -45,4 +51,6 @@ Prism.hooks.add('complete', function (env) {

env.element.appendChild(lineNumbersWrapper);

});
});

}());
2 changes: 1 addition & 1 deletion plugins/line-numbers/prism-line-numbers.min.js

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

12 changes: 10 additions & 2 deletions plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
Prism.hooks.add('before-highlight', function(env) {
(function() {

if (typeof self === 'undefined' || !self.Prism || !self.document) {
return;
}

Prism.hooks.add('before-highlight', function (env) {
if (env.code) {
var pre = env.element.parentNode;
var clsReg = /\s*\bkeep-initial-line-feed\b\s*/;
Expand All @@ -10,4 +16,6 @@ Prism.hooks.add('before-highlight', function(env) {
env.code = env.code.replace(/^(?:\r?\n|\r)/, '');
}
}
});
});

}());

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

5 changes: 4 additions & 1 deletion plugins/show-invisibles/prism-show-invisibles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(function(){

if(!window.Prism) {
if (
typeof self !== 'undefined' && !self.Prism ||
typeof global !== 'undefined' && !global.Prism
) {
return;
}

Expand Down
Loading

0 comments on commit 0356c58

Please sign in to comment.