Skip to content

Commit

Permalink
Removed parent from the wrap hook's environment (#1837)
Browse files Browse the repository at this point in the history
This removes the `parent` property of the `wrap` hook and the parameter from `Token.stringify`.
  • Loading branch information
RunDevelopment committed Mar 28, 2019
1 parent 0f16eb8 commit 65a4e89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
10 changes: 4 additions & 6 deletions components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,25 +459,24 @@ function Token(type, content, alias, matchedStr, greedy) {
this.greedy = !!greedy;
}

Token.stringify = function(o, language, parent) {
Token.stringify = function(o, language) {
if (typeof o == 'string') {
return o;
}

if (Array.isArray(o)) {
return o.map(function(element) {
return Token.stringify(element, language, o);
return Token.stringify(element, language);
}).join('');
}

var env = {
type: o.type,
content: Token.stringify(o.content, language, parent),
content: Token.stringify(o.content, language),
tag: 'span',
classes: ['token', o.type],
attributes: {},
language: language,
parent: parent
language: language
};

if (o.alias) {
Expand All @@ -492,7 +491,6 @@ Token.stringify = function(o, language, parent) {
}).join(' ');

return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';

};

if (!_self.document) {
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.

10 changes: 4 additions & 6 deletions prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,25 +464,24 @@ function Token(type, content, alias, matchedStr, greedy) {
this.greedy = !!greedy;
}

Token.stringify = function(o, language, parent) {
Token.stringify = function(o, language) {
if (typeof o == 'string') {
return o;
}

if (Array.isArray(o)) {
return o.map(function(element) {
return Token.stringify(element, language, o);
return Token.stringify(element, language);
}).join('');
}

var env = {
type: o.type,
content: Token.stringify(o.content, language, parent),
content: Token.stringify(o.content, language),
tag: 'span',
classes: ['token', o.type],
attributes: {},
language: language,
parent: parent
language: language
};

if (o.alias) {
Expand All @@ -497,7 +496,6 @@ Token.stringify = function(o, language, parent) {
}).join(' ');

return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';

};

if (!_self.document) {
Expand Down

0 comments on commit 65a4e89

Please sign in to comment.