Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ var _self = (typeof window !== 'undefined')
* @author Lea Verou http://lea.verou.me
*/

var Prism = (function(){
var Prism = (function (_self){

// Private helper vars
var lang = /\blang(?:uage)?-([\w-]+)\b/i;
var uniqueId = 0;

var _ = _self.Prism = {
var _ = {
manual: _self.Prism && _self.Prism.manual,
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
util: {
Expand Down Expand Up @@ -269,8 +269,6 @@ var _ = _self.Prism = {
},

matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
var Token = _.Token;

for (var token in grammar) {
if(!grammar.hasOwnProperty(token) || !grammar[token]) {
continue;
Expand Down Expand Up @@ -436,17 +434,21 @@ var _ = _self.Prism = {
callback(env);
}
}
}
},

Token: Token
};

var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
_self.Prism = _;

function Token(type, content, alias, matchedStr, greedy) {
this.type = type;
this.content = content;
this.alias = alias;
// Copy of the full string this token was created from
this.length = (matchedStr || "").length|0;
this.greedy = !!greedy;
};
}

Token.stringify = function(o, language, parent) {
if (typeof o == 'string') {
Expand Down Expand Up @@ -487,7 +489,7 @@ Token.stringify = function(o, language, parent) {
if (!_self.document) {
if (!_self.addEventListener) {
// in Node.js
return _self.Prism;
return _;
}

if (!_.disableWorkerMessageHandler) {
Expand All @@ -505,7 +507,7 @@ if (!_self.document) {
}, false);
}

return _self.Prism;
return _;
}

//Get current script and highlight
Expand All @@ -528,9 +530,9 @@ if (script) {
}
}

return _self.Prism;
return _;

})();
})(_self);

if (typeof module !== 'undefined' && module.exports) {
module.exports = Prism;
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.

24 changes: 13 additions & 11 deletions prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ var _self = (typeof window !== 'undefined')
* @author Lea Verou http://lea.verou.me
*/

var Prism = (function(){
var Prism = (function (_self){

// Private helper vars
var lang = /\blang(?:uage)?-([\w-]+)\b/i;
var uniqueId = 0;

var _ = _self.Prism = {
var _ = {
manual: _self.Prism && _self.Prism.manual,
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
util: {
Expand Down Expand Up @@ -274,8 +274,6 @@ var _ = _self.Prism = {
},

matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
var Token = _.Token;

for (var token in grammar) {
if(!grammar.hasOwnProperty(token) || !grammar[token]) {
continue;
Expand Down Expand Up @@ -441,17 +439,21 @@ var _ = _self.Prism = {
callback(env);
}
}
}
},

Token: Token
};

var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
_self.Prism = _;

function Token(type, content, alias, matchedStr, greedy) {
this.type = type;
this.content = content;
this.alias = alias;
// Copy of the full string this token was created from
this.length = (matchedStr || "").length|0;
this.greedy = !!greedy;
};
}

Token.stringify = function(o, language, parent) {
if (typeof o == 'string') {
Expand Down Expand Up @@ -492,7 +494,7 @@ Token.stringify = function(o, language, parent) {
if (!_self.document) {
if (!_self.addEventListener) {
// in Node.js
return _self.Prism;
return _;
}

if (!_.disableWorkerMessageHandler) {
Expand All @@ -510,7 +512,7 @@ if (!_self.document) {
}, false);
}

return _self.Prism;
return _;
}

//Get current script and highlight
Expand All @@ -533,9 +535,9 @@ if (script) {
}
}

return _self.Prism;
return _;

})();
})(_self);

if (typeof module !== 'undefined' && module.exports) {
module.exports = Prism;
Expand Down