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

Investigate monkey patch of PrismJS #905

Closed
jcubic opened this issue Dec 3, 2023 · 1 comment
Closed

Investigate monkey patch of PrismJS #905

jcubic opened this issue Dec 3, 2023 · 1 comment
Labels
feature resolved if issue is resolved, it will be open until merge with master

Comments

@jcubic
Copy link
Owner

jcubic commented Dec 3, 2023

I have an idea for a new feature for jQuery Terminal

This is the code for the highlight function from PrismJS:

highlight: function (text, grammar, language) {
	var env = {
		code: text,
		grammar: grammar,
		language: language
	};
	_.hooks.run('before-tokenize', env);
	if (!env.grammar) {
		throw new Error('The language "' + env.language + '" has no grammar.');
	}
	env.tokens = _.tokenize(env.code, env.grammar);
	_.hooks.run('after-tokenize', env);
	return Token.stringify(_.util.encode(env.tokens), env.language);
},

There is a need to test with different grammars if those hooks make a difference. I was told they do.

@jcubic jcubic added the feature label Dec 3, 2023
@jcubic jcubic changed the title Investiage monkey patch of PrismJS Investigate monkey patch of PrismJS Dec 3, 2023
jcubic added a commit that referenced this issue Dec 3, 2023
@jcubic
Copy link
Owner Author

jcubic commented Dec 3, 2023

I'm not sure if there are any differences but for the sake of having the same code as prism. I've added the hooks.

@jcubic jcubic added the resolved if issue is resolved, it will be open until merge with master label Dec 3, 2023
@jcubic jcubic closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature resolved if issue is resolved, it will be open until merge with master
Projects
None yet
Development

No branches or pull requests

1 participant