CS-Notes/docs/_style/prism-master/plugins/custom-class/prism-custom-class.js

32 lines
559 B
JavaScript
Raw Normal View History

2018-12-19 14:09:39 +08:00
(function(){
if (
(typeof self === 'undefined' || !self.Prism) &&
(typeof global === 'undefined' || !global.Prism)
) {
return;
}
var options = {
classMap: {}
};
Prism.plugins.customClass = {
map: function map(cm) {
options.classMap = cm;
},
prefix: function prefix(string) {
options.prefixString = string;
}
}
Prism.hooks.add('wrap', function (env) {
if (!options.classMap && !options.prefixString) {
return;
}
env.classes = env.classes.map(function(c) {
return (options.prefixString || '') + (options.classMap[c] || c);
});
});
})();