Page 1 of 1

Macro: convert format markers to formatted text

Posted: 2012-04-17 21:56:57
by NisusUser
I don't yet have any meaningful skills with Nisus WP's macros. (I'm using 2.0.2). I am testing Transcriva (http://www.bartastechnologies.com/products/transcriva/), attempting to transcribe a recording. Transcriva does not support bold, italic, or underlined text. I'm thinking that if, when transcribing, I inserted markers around text I'd like formatted, then when I export .rtf files, I could have a macro in NWP that would apply the formatting and remove the markers. I am thinking of markers like

Code: Select all

[B]bold[/B] and [b]bold[/b],  [I]italics[/I] and [i]italics[/i], and [U]underline[/U],  [u]underline[/u]
How do I make a macro like this? Or does someone want to do one for me? :) Thanks!

Re: Macro: convert format markers to formatted text

Posted: 2012-04-18 00:33:15
by phspaelti
Hello NisusUser.

writing such a macro is possible and is in fact quite easy. The key is to use "Find and Replace".
  1. Open "Find and Replace"
  2. Select "Using: PowerFind"
  3. Enter your opening tag, i.e.,

    Code: Select all

    "[b]"
  4. From the gear menu choose Match > Capture(). The cursor should be between the two parts of the Capture()
  5. From the gear menu choose Wild Card > AnyCharacter
  6. From the gear menu choose Repeat > 1+ Shortest
  7. Place the cursor at the end of the find expression and enter your closing tag, i.e.,

    Code: Select all

    "[/b]"
  8. Move to the Replace box and from the (replace) gear menu choose Match > Captured1
  9. Select the replace expression and apply bold formatting as usual. The "Replace Attributes" box should become "clicked"
The find box should look like this:
Macroize_1.jpg
Macroize_1.jpg (32.26 KiB) Viewed 9279 times
If you do "Replace All" now on a file with that kind of mark up you should have your mark up turned into formatting.
NB: Since "Ignore Case" is checked, this will work for tags with either "b" or "B" in any mixed combination. (This seems to be what you want.)

To get a macro, you do the following.
  1. From the gear menu choose "Macroize…"
    choosing "Macroize…"
    choosing "Macroize…"
    Macroize_2.jpg (55.28 KiB) Viewed 9279 times
  2. In the macroize window specify "Replace All" and then do "Save as Macro"
    Save as "Replace all" macro
    Save as "Replace all" macro
    Macroize_3.jpg (33.46 KiB) Viewed 9279 times
Repeat the whole thing for the other tags. :!: Make sure to apply the formatting you want -- and to clear out any formatting you don't want -- in the replace box. :!:
You'll have to use copy/paste to combine the 3 macros into 1.

Re: Macro: convert format markers to formatted text

Posted: 2012-04-18 00:34:45
by phspaelti
Anyhow here is a completed macro. (My version uses Powerfind Pro).
NisusUserTagToFormatting.nwm
(18 KiB) Downloaded 870 times

Re: Macro: convert format markers to formatted text

Posted: 2012-04-18 09:24:53
by NisusUser
Thank you, Phillip! I'll try to work through the stuff you taught me, and see if I can learn how to do some of this for myself. I can foresee some other macros I need, so getting some skills in this area will be great. Thanks so much!