Sunday, July 22, 2018

Syntax Highlighting Here

Syntax Highlighting Here


One of the reasons I took a long hiatus at this blog was because I learned how to do syntax highlighting in my posts and it was such a laborious process that I quickly tired of it because posting became such a daunting task.

But scripts are supposed to make daunting tasks more manageable, possibly even eliminating the daunt altogether. Thats the first time Ive ever used "daunt" as a noun like that. Probably not good English.

If youve ever looked at ESTKs preferences, youll see that it offers about a million syntax highlighting controls. Theres no way I want to duplicate that lot. My sights are set much lower. If I can highlight reserved words in blue, strings in red, and comments in green, Ill be happy.

The interesting thing is that Ive already solved this problem in InDesign itself. When I want to showJS code in an InDesign document, I use a paragraph style with a bunch of GREP styles. I cant do that here, but perhaps I can use similar GREPs to get the right tags around the right text to achieve the desired effect.

And with that, the thought occurs that perhaps I can write a script that pulls the GREP search values out of the paragraph style so I dont have to maintain them in more than one place. Sounds like a fun project. Lets give it a shot.

More to come ...


visit link download