highlight-js icon indicating copy to clipboard operation
highlight-js copied to clipboard

Different highlight class

Open oozrafa opened this issue 11 years ago • 6 comments

Hey!

I was wondering if there's a way to add different classes for each word when an array is used. This way each word can have a different highlight colour.

oozrafa avatar Apr 04 '13 12:04 oozrafa

@oozrafa That might be slightly complicated. Of course we can modify the array to be an array of objects like so [{pattern: "multi", highlightClass: "rainbow"}] instead of just array of Strings. But then how are we gonna implement the removeHighlight method? Remember there is no instance variable where we can store the state of what highlight classes were used. Even if we hacked it to save that, I am slightly concerned about the performance hit. Do you want to create a quick prototype on http://jsfiddle.com or something and use http://jsperf.com/ to measure the performance on differing sized corupses?

tankchintan avatar Apr 04 '13 13:04 tankchintan

Maybe remove highlight could also accept an array of classes as an argument when triggered, and if none is specified then use the default one.

oozrafa avatar Apr 04 '13 14:04 oozrafa

Hmm. We could do that. Do you want to open a PR for this?

tankchintan avatar Apr 04 '13 14:04 tankchintan

a PR?

oozrafa avatar Apr 09 '13 11:04 oozrafa

Oh. I am sorry I meant Pull Request. Basically make the changes in your copy of forked/cloned code and submit a request for me to merge the changes.

tankchintan avatar Apr 09 '13 13:04 tankchintan

@oozrafa I have another project started as a fork of the same plugin as highlight-js from @tankchintan. Then I refactored everything. The plugin supports the feature which you missed, and a lot of others too.

julkue avatar Jan 07 '16 14:01 julkue