Skip to content

Commit

Permalink
Reuse apply function
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Jun 22, 2021
1 parent fe54d2c commit 435ecfe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions plugins/custom-class/prism-custom-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
var prefixString = '';


/**
* @param {string} className
* @param {string} language
*/
function apply(className, language) {
return prefixString + (mapper ? mapper(className, language) : className);
}


Prism.plugins.customClass = {
/**
* Sets the function which can be used to add custom aliases to any token.
Expand Down Expand Up @@ -71,9 +80,7 @@
*
* If the language is unknown, pass `"none"`.
*/
apply: function (className, language) {
return prefixString + (mapper ? mapper(className, language) : className);
}
apply: apply
};

Prism.hooks.add('wrap', function (env) {
Expand All @@ -96,7 +103,7 @@
}

env.classes = env.classes.map(function (c) {
return prefixString + (mapper ? mapper(c, env.language) : c);
return apply(c, env.language);
});
});

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

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

0 comments on commit 435ecfe

Please sign in to comment.