I'm trying to write a routine that will copy selected text to the clipboard, but with italics identified and then wrapped with "<ital>", "</ital>" tags. . .but not have the text change in the selection in the document, only in the string going to the clipboard.
I can execute the find, and i can send strings to the clipboard but i haven't resolved the italics issue itself.
Any ideas for approaches?
I thought about trying run a find, then loop through each italic string found in the selection, create a list of locations (I can iterate and add items to a list, right?) and then use those locations to act on the string, starting from the back of the string and adding the tags. One trouble spot in this approach: is there syntax for identifying the location (character count/insertion point) of some found text within a selection?
Or can anyone think of easier ways to do this?
any help would be much obliged!
Can you give us a clue, what you are doing next with the clipboard content? I ask, because it can be better to do the tagging afterwards.
Another idea is to use XML. Find all italics in document and add the <ital>-tag (shoudn't change anything in the document). Then copy/paste the XML code.
Make a temporary text frame, paste content, do the tagging, content to clipboard, delete text frame.
(You may create the temporary text frame at the beginning of the script, use it throughout the script for conversion, and delete it at the end of the script. Or create and delete with every clipboard item - as it fits.)
Tobias, thanks very much. You are quite right on all these counts. However for a variety of reasons I decided on an approach that would make the changes in the live text, get it to the clipboard, then remove the extra tags thus resetting the new text back to the old. I did it mostly using text style range feature which works nicely so far.