Article View: adobe.scripting.indesign
Article #17293Re: (AS) OT fractions feature?
From: Jay Fraser
Date: Mon, 23 Jun 2003 22:43
Date: Mon, 23 Jun 2003 22:43
53 lines
2345 bytes
2345 bytes
Eric --
Here's something for your parenthesis. It assumes you have a character style "Emphasis", plus a swatch w/ 100% magenta.
tell application "InDesign 2.0.2"
set myDocument to active document
tell myDocument
set myPink to swatch "C=0 M=100 Y=0 K=0"
set myStory to object reference of parent story of selection
set myStyle to character style "Emphasis"
tell myStory
repeat with i from (count paragraphs) to 1 by -1
try
set myOpenParen to index of (character 1 whose contents = "(") of paragraph i
set myCloseParen to index of (character 1 whose contents = ")") of paragraph i
set applied character style of characters myOpenParen thru myCloseParen to myStyle
set contents of character myCloseParen to ""
set contents of character myOpenParen to ""
on error
set fill color of text of paragraph i to myPink
end try
end repeat
end tell
end tell
end tell
There's a bit of an issue in that if the script doesn't find an opening paren and a closing paren, it turns the whole paragraph pink. That's good if only 1 is missing, but it'll be a bother if both are missing, because it means you don't want to emphasize anything. I'll see if I can get the error-checking to work right, but this'll get you started.
jay
Technical Details
Message-ID:
<1de9a683.4@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de9a683.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,f332520123d2c8c6 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-06-23 16:07:55 PST From: "Jay Fraser" <jayfraser@yahoo.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: (AS) OT fractions feature? Message-ID: <1de9a683.4@WebX.la2eafNXanI> Date: Mon, 23 Jun 2003 15:43:39 -0700 References: <1de9a683.-1@WebX.la2eafNXanI> Lines: 38 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit