nisus.com
https://www.nisus.com/forum/

macro: preserve some character attributes, but add italics
https://www.nisus.com/forum/viewtopic.php?f=17&t=5168
Page 1 of 1

Author:  NisusUser [ 2012-11-28 06:35:40 ]
Post subject:  macro: preserve some character attributes, but add italics

I want to change [this] to this, or [this] to this, or [this] to this, i.e. text with brackets to italicized text. However, sometimes the target text in brackets already has bold, underline or such applied. All I want is to add italics. I'm using the PowerFind Pro find and replace formula in the attached screenshot. However, if the text has other attributes applied, it removed them and adds back italics only. How can I get want I need? Do I need to do separate find/replace functions for differing text, i.e. one for text already in bold, one for text already in bold & underline, one for text that has no attributes applied yet, etc.?

Attachments:
imprecise find-replace_deletes formatting.png
imprecise find-replace_deletes formatting.png [ 28.09 KiB | Viewed 3682 times ]

Author:  phspaelti [ 2012-11-28 07:32:21 ]
Post subject:  Re: macro: preserve some character attributes, but add itali

I would use a macro for this. Then rather than do Find and Replace, I would do this:
Code:
Find All ...
Italic

So I'd just use the Find capability to Find things and then apply the formatting "by hand" (so to speak).
Hope this helps.

Author:  NisusUser [ 2012-11-28 20:44:21 ]
Post subject:  Re: macro: preserve some character attributes, but add itali

Philip,

I guess I don't know fully the difference between Find and Replace and a macro. I was just assuming a macro was a Find and Replace expression that was saved and run as a macro. Maybe you can help me out as to what you meant.

Attached is a macro I made to do this. For some reason it doesn't work, though. I thought I followed your examples. Would you be willing to help me out?

Thanks!

Attachments:
EC-brackets to italics.nwm [823 Bytes]
Downloaded 224 times

Author:  phspaelti [ 2012-11-29 05:07:28 ]
Post subject:  Re: macro: preserve some character attributes, but add itali

Hi I have fixed your macro.(Keeping my fingers crossed.) If you do it right then you don't need three Find/Replace statements. Your last one will suffice.

Attachment:
EC-brackets_to_italics_(simple).nwm [3.09 KiB]
Downloaded 244 times


What does "do it right mean"? Well the attribute sensitive find/replace pays attention to the attributes. All the attributes. So once you paste the statement into a file it takes on other attributes (paragraph style, for example), and then it stops working. The solution for such cases is to use the "Remove Attributes and Styles" command, and then add back just the attributes you want.

to be continued…

Author:  phspaelti [ 2012-11-29 05:12:22 ]
Post subject:  Re: macro: preserve some character attributes, but add itali

Anyhow I hate fussing with the attributes so I suggested a second method.

Attachment:
EC-brackets_to_italics_(2_step).nwm [3.14 KiB]
Downloaded 221 times


As I described above, you can use Find/Replace to select things, and then apply the styles you want. As long as the Find part doesn't care about styles, this works, a bit more "reliably".

A macro can contain more than just a list of Find/Replace statements. You can add any menu commands (just type them exactly as the menu name says), and then there is a whole macro language if you want to get really elaborate.

Anyhow good luck with your macro writing. :wink:

Author:  NisusUser [ 2012-11-29 07:04:45 ]
Post subject:  Re: macro: preserve some character attributes, but add itali

Thank you very much for all your help and tutoring!

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/