🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16652

Re: Scripting to replace quoted content with Italic?

#16652
From: Dave Saunders
Date: Wed, 06 Aug 2003 11:27
19 lines
2309 bytes
As a strategy (I'm an AppleScripter, so code won't help), go about it like this:

1. Determine the scope over which your script should operate (Selection, Story, Document).

- I usually do this by checking the class of the selection. If it is text, then I assume the script should operate only on that text. Otherwise, if the parent story property exists (e.g., single insertion point or text frame selected), then I operate over the parent story. Otherwise, I just hit the whole document.

2. Use a scripted search to make a list of references of every instance of opening quote. (Note that it is actually much easier to do this if you do have smart quotes because there's no chance of confusing a start with an end marker).

3. Process the list backwards (necessary because we're going to be deleting characters so we want to do that from the back forwards so that the list of references we still have to process is still a good list).

4. For each item on the list, you need to find the corresponding closing quote. There are various ways to do this. You might want to make sure that the first one found is actually in the same paragraph as the opening quote to avoid setting huge swathes of text to italic.

- I'd probably construct a text reference to the characters from the current opening quote to the end of its paragraph and then do a Find on that to seek the closing quote; if it's not found, either move on and ignore or log an error.

5. To actually apply the italic, I recommend using a character style.

I hope this helps.

Dave
Technical Details
Message-ID: <1dea3379.3@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1dea3379.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,e0d99fb5835edf35
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-08-06 04:37:49 PST
From: "Dave Saunders" <daves@pdsassoc.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Scripting to replace quoted content with Italic?
Message-ID: <1dea3379.3@WebX.la2eafNXanI>
Date: Wed, 6 Aug 2003 04:27:38 -0700
References: <1dea3379.-1@WebX.la2eafNXanI>
Lines: 36
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit