Transform text between ++ to comments

Get help using and writing Nisus Writer Pro macros.
Post Reply
thf
Posts: 64
Joined: 2006-10-13 11:26:49

Transform text between ++ to comments

Post by thf » 2010-06-22 04:48:34

Hi, im looking for a macro whih transfers a text between ++ symbols to comments. Is there any possibility to achieve this. my text goes something like this

bla bla bla ++explicate this++ bla bla bla

any help?

Yours tom

User avatar
martin
Official Nisus Person
Posts: 4354
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Transform text between ++ to comments

Post by martin » 2010-06-22 08:48:33

Hi Tom- a macro like that is not too tough. Here's one:

Code: Select all

Select Document Start
While Find Next '\+\+\s*(.+?)\s*\+\+\s*', 'E$'
	Delete
	Add Comment
	Insert Attributed Text $1
	Go to Marked Text
End
That will preserve any formatting applied to the comment text. If you want to strip formatting from the comments, you can change the "Insert Attributed Text" command to just "Insert Text".

thf
Posts: 64
Joined: 2006-10-13 11:26:49

Re: Transform text between ++ to comments

Post by thf » 2010-06-22 11:19:17

Thanks a lot. I have found almost everything I need for the german version, which comes that way.

Select Document Start
While Find Next '\+\+\s*(.+?)\s*\+\+\s*', 'E$'
   Löschen
Kommentar erstellen
   Insert Attributed Text $1
Gehe zum markierten Text
End

I don't know if the question ever arised, but it would be very helpful if the macros wouldn't be language dependent (maybe in a future version?)

Yours,
Thomas

Did I say "Thank you!" - i didn't: shame on me :oops: Thank you, the macro does a perfect job.

User avatar
martin
Official Nisus Person
Posts: 4354
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Transform text between ++ to comments

Post by martin » 2010-06-25 09:32:27

I'm glad you got it working (and translated) Thomas.

Yes, it would be much better if one didn't have to translate the menu names in a macro. It's an annoyance we wish didn't exist, but the situation is a little complicated, so I'm not sure you'll see any progress soon.

Post Reply