Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: VSCode friendly #1776

Merged
merged 2 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -278,8 +278,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 @@ -445,17 +443,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 @@ -496,7 +498,7 @@ Token.stringify = function(o, language, parent) {
if (!_self.document) {
if (!_self.addEventListener) {
// in Node.js
return _self.Prism;
return _;
}

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

return _self.Prism;
return _;
}

//Get current script and highlight
Expand All @@ -537,9 +539,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.

2 changes: 1 addition & 1 deletion components/prism-sas.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 @@ -283,8 +283,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 @@ -450,17 +448,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 @@ -501,7 +503,7 @@ Token.stringify = function(o, language, parent) {
if (!_self.document) {
if (!_self.addEventListener) {
// in Node.js
return _self.Prism;
return _;
}

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

return _self.Prism;
return _;
}

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

return _self.Prism;
return _;

})();
})(_self);

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