Macro: convert format markers to formatted text

Get help using and writing Nisus Writer Pro macros.
Post Reply
NisusUser
Posts: 257
Joined: 2011-01-12 05:32:38

Macro: convert format markers to formatted text

Post by NisusUser » 2012-04-17 21:56:57

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!

User avatar
phspaelti
Posts: 889
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Macro: convert format markers to formatted text

Post by phspaelti » 2012-04-18 00:33:15

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 4445 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…"
    Macroize_2.jpg
    choosing "Macroize…"
    Macroize_2.jpg (55.28 KiB) Viewed 4445 times
  2. In the macroize window specify "Replace All" and then do "Save as Macro"
    Macroize_3.jpg
    Save as "Replace all" macro
    Macroize_3.jpg (33.46 KiB) Viewed 4445 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.
Last edited by phspaelti on 2012-04-18 00:48:20, edited 4 times in total.
philip

User avatar
phspaelti
Posts: 889
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Macro: convert format markers to formatted text

Post by phspaelti » 2012-04-18 00:34:45

Anyhow here is a completed macro. (My version uses Powerfind Pro).

[The extension nwm has been deactivated and can no longer be displayed.]

philip

NisusUser
Posts: 257
Joined: 2011-01-12 05:32:38

Re: Macro: convert format markers to formatted text

Post by NisusUser » 2012-04-18 09:24:53

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!

Post Reply