Monday, January 09, 2012

 

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. That's the first time I've ever used "daunt" as a noun like that. Probably not good English.

If you've ever looked at ESTK's preferences, you'll see that it offers about a million syntax highlighting controls. There's 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, I'll be happy.

The interesting thing is that I've 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 can't 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 don't have to maintain them in more than one place. Sounds like a fun project. Let's give it a shot.

More to come ...

Saturday, January 07, 2012

 

PopTabUnleashed

When InDesign CS4 hit the streets, I thought that PopTabFmClip was obsolete. I said so on my web site and basically abandoned it. But it turns out that there's one thing that PopTab did that isn't available in native InDesign. If you want to copy the content of one InDesign table into another (target) table without losing the formatting of the target table, then PopTab is the answer.

So, over the holidays, I decided to rework PopTab to make it available for users of CS4 and later. And I also decided to release it in source form so people are free to read its code if they wish. I'll examine the code here in this blog too to explain the techniques it uses. But the purpose of this blog entry is to announce the availability of PopTabUnleashed -- there's a link at the left of this page you can use to download it.

Here's how the script describes itself in the introductory comment at the head of its code:

This script is provided as-is. Use at your own risk.

The script populates a table, or part of a table, with the text/values on the clipboard without changing the formatting/styling of the target table. The effects of running the script can be undone using Edit/Undo Populate Table.

The content of the clipboard is expected to be a table or part of a table. It can be a selection from Excel or any other application that exports table data, but you hardly need this script to support external applications because since CS4, InDesign provides this functionality: just paste into an existing table.

PopTab comes into its own when you're copying from one InDesign table to another. That is not natively supported because the formatting of the source table is included when you paste.

The selection is required to be in a table. It can be text in a cell, a cell, a range of cells, or a complete table. Selecting text in a cell is regarded as the same as selecting the cell.
As always, just move the script into your Scripts Panel folder so it is visible in your Scripts Panel. To use it, copy appropriate content to the clipboard, make a selection in your target table and then trigger the script to move the clipboard content into the table.

This page is powered by Blogger. Isn't yours?