Insert text without picking up local overrides


okay, time give , ask help....

 

i'm trying write extendscript insert tags around text style range without picking formatting of text style range. example, find italicized "photography theory" in middle of paragraph of non-italic text this:

 

my own thoughts strange second volume of series, photography theory, in “is listening?,” photofile 80 (winter 2007): 80.

 

and put "<i> before , "</i>" after it. able add tags using insertionpoint object, closing tag takes on formatting of text style range. rather, need take on underlying applied paragraph style no modifications.

 

i have tried using insertionpoint.clearoverrides both before , after insertion of tag, doesn't work.

 

because there many kinds of "italic" font styles—oblique, cursive, kursive, cursiv, slanted, , on , on—i can't use find/change.

 

i open using find routine later in script searches "<i>" , "</i>" , clears overrides on them, again, can't change function, have find each tag 1 @ time apply clearoverrides it. seems me incredibly slow, i'd rather not go route. (also, first extendscript, , can figure out how loop iterate through each instance , stop—i can in sleep loop in vba, i'm not there yet javascript).

 

thanks thoughts on how plant tag without picking overrides.

 

m.

@linuscmh – think problem here last insertion point of text style range includes formatting want avoid.

 

what do:
create "tags" in new text frame (in fact no "tags", chunks of formatted text), apply right formatting , move opening , closing "tags" appropriate insertion points. afterwards can remove temp text frame.

 

do not attempt "contents" property of insertion point, "texts" object.

 

one example code:

supposed italic text want surround "tags" selected…

 

var sel = app.selection[0];  var myclosinginsertionpoint = sel.insertionpoints[-1]; var myopeninginsertionpoint = sel.insertionpoints[0];  var myparastyle = sel.appliedparagraphstyle; var mytemptf = app.documents[0].textframes.add({geometricbounds:[0,0,100,100]});  mytemptf.texts[0].appliedparagraphstyle = myparastyle; mytemptf.texts[0].contents = "<i>"+"</i>";  mytemptf.texts[0].characters.itembyrange(3,6).move(locationoptions.after,myclosinginsertionpoint); mytemptf.texts[0].characters.itembyrange(0,2).move(locationoptions.after,myopeninginsertionpoint);  mytemptf.remove(); 

 

since not know code, cannot say, if can implement suggestion easily…

 

uwe



More discussions in InDesign Scripting


adobe

Comments

Popular posts from this blog

Thread: gpg: Conflicting Commands

Thread: World of Warcraft private server with wine?

Thread: video metadata editing??