erosman / CodeMirror-plus

Additonal features for CodeMirror
Mozilla Public License 2.0
10 stars 2 forks source link

Regex Support #2

Open rhpo opened 2 years ago

rhpo commented 2 years ago

Please add a Regex support to colorise keywords, for example, words that Starts with an uppercase character.

erosman commented 2 years ago

That is possible but it would be a breaking change as object properties don't allow Regex. Let me think....

erosman commented 2 years ago

I have uploaded a new version. Please test it and let me know.

Uka-Uka commented 2 years ago

Great work, @erosman! do you think we can take advantage of this to highlight colors in CSS?

erosman commented 2 years ago

do you think we can take advantage of this to highlight colors in CSS?

What is that exactly?

Uka-Uka commented 2 years ago

do you think we can take advantage of this to highlight colors in CSS?

What is that exactly?

I'm wondering if we could possibly use regex to select hex color codes in CSS and give it some styles like background-color which would inherit its value from the selected code. image

erosman commented 2 years ago

I do it in FireMonkey, although slightly differently, but it requires more code and I actually alter the codemirror.js. In FireMonkey, I set the hex value as a style parameter and then convert it to style.

With this addon, you can set static styles but since there are many possible colours, it is not practical to set them all.

rhpo commented 2 years ago

I have uploaded a new version. Please test it and let me know.

So is there some examples i can try ?

/* ex: */ CodeMirror.colorise(/(?<=<)(.+?)*(?=>)/) 
erosman commented 2 years ago

So is there some examples i can try ?

Examples are in the README.md

rhpo commented 2 years ago

Hey @erosman, Do you have anything i can contact you in (email, instagram, discord server...) it's about a developement subject. in case you don't, here are mine: me@ramey.ml @ramyhadid

erosman commented 2 years ago

Hey @erosman, Do you have anything i can contact you in (email, instagram, discord server...) it's about a developement subject. in case you don't, here are mine: me@ramey.ml @ramyhadid

I visit https://chat.mozilla.org/#/room/#addons:mozilla.org & https://chat.mozilla.org/#/room/#addon-reviewers:mozilla.org regularly.