Skip to content

Commit

Permalink
trigger hooks in prism monkey patch #905
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Dec 3, 2023
1 parent 1ae4235 commit cd62295
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions js/prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,15 @@
}
if (language && _.languages[language]) {
string = $.terminal.unescape_brackets(string);
var grammar = _.languages[language];
var tokens = _.tokenize(string, grammar);
string = _.Token.stringify(tokens, language);
var env = {
code: string,
grammar: _.languages[language],
language: language
};
_.hooks.run('before-tokenize', env);
env.tokens = _.tokenize(env.code, env.grammar);
_.hooks.run('after-tokenize', env);
string = _.Token.stringify(env.tokens, env.language);
string = string.split(format_split_re).filter(Boolean).map(function(string) {
if (string.match(/^\x00/)) {
return string.replace(/\x00/g, '');
Expand Down

0 comments on commit cd62295

Please sign in to comment.