New Javascript-based Xojo syntax highlighter

Hi,

I’ve just recently switched from PrismJS to Rainbow for highlighting code on web pages. I’ve released a plugin for the library to allow highlighting of Xojo code. I’ve also included CSS/SASS files for a light and dark theme which match the default colours used by the Xojo IDE. Hopefully someone will find it useful.

GitHub Repo.

Hi Garry,

great job, thanks. What I notice, colors are not yet recognized. Do you see a possibility to modify your code, so that colors according to the pattern “&cFFFFFF00” (RRGGBBAA) will be displayed the same way as in the Xojo?

[quote=425421:@Martin Trippensee]Hi Garry,

great job, thanks. What I notice, colors are not yet recognized. Do you see a possibility to modify your code, so that colors according to the pattern “&cFFFFFF00” (RRGGBBAA) will be displayed the same way as in the Xojo?[/quote]
Ah my oversight. Sorry. Sure, I’ll do that this evening.

@Martin Trippensee: I’ve updated the repo. The plugin now correctly highlights Color literals just like the IDE does. Light and dark colour scheme added too.

Hmm. I think the ampersand needs to be HTML encoded to &. Does that work?

Nope. Colors should also be matched, if optional alpha values are used (&cFB010600). Pattern should look like this one:

/(&c)([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})?\\b/gi

Ah, my bad. I had updated the SASS files but I hadn’t re-built the CSS files. The Repo has been updated now.

Right. I think that’s done now. Could you check?

The alpha value is optional, otherwise colors without alpha value won’t match. You forgot the question mark in the pattern.

Done now. I think.

Blimey - I need to test more!

I think we all need to do more of that.

Hey… You talking to ME? :slight_smile:

I wasnt speaking to anyone in particular (well outside of myself!). But how many of us programmers like writing test code and write test code for everything? that would be a very small number, approaching zero. I try to write 10 (arbitary number I pulled out of my backside) UnitTests for every method I write. dont get me wrong, i dont. I try. then when I (or someone else) finds a bug/issue/edge-case that the code doesnt work, I write a UnitTest (or several) around that, and add them to the UnitTests.

and I know your comment was in good spirits/jokingly but for some that read our banter might not have seen it that way.

back to coding! maybe today I can actually write some Xojo code.

It was :slight_smile: [in relation to another on-going topic]