Convert Hyperlinks to HTML

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
loulesko
Posts: 124
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Convert Hyperlinks to HTML

Post by loulesko »

Here's a macro to convert Nisus Hyperlinks to HTML code. I use this as part of a macro that converts a Nisus document to blog friendly text. I thought it might be useful on its own.

If you have a word or a section of your Nisus document that is embedded with a hyperlink, this macro will select it and turn the blue underlined words into the display text and the underlying link into the href.

Again, my thanks to Kino. I took code from other things he's done on this forum to make this work.

Code: Select all

Select Document Start
While Select Next Link
    $sel = TextSelection.active
    $text = $sel.subtext
    $attr = $sel.text.displayAttributesAtIndex $sel.location
    $url = $attr.link
    Set Link ''
    Insert Text "<a href=\"$url\">$text</a>"
end
Select End
Last edited by loulesko on 2011-04-22 22:52:29, edited 1 time in total.
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Convert Hyperlinks to HTML

Post by martin »

Thanks for taking the time to post your macros to the forum Lou- I appreciate that, as I'm sure others do.

One tip: you do not need to include naming directives in your macros, eg:

Code: Select all

#NisusMacroProperty Name: Hyperlinks to HTML
By default NWP will use the macro's file name for the macro's name / menu title inside NWP. Including the directive is only necessary if you want to override the file's name.

You probably picked up the habit by looking at the macros we distribute with NWP. We include the naming directive in those macros because of localization, eg: if a user is running NWP in French, we want the macro's menu title to display in French as well. The naming directive also implies localization.
User avatar
loulesko
Posts: 124
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: Convert Hyperlinks to HTML

Post by loulesko »

Hi Martin,

Gotchya. Thanks for pointing that out. Much appreciated.

I edited the macro above.

Lou
bobmacatq
Posts: 13
Joined: 2011-01-14 17:49:49

Re: Convert Hyperlinks to HTML

Post by bobmacatq »

Folks!

I'm trying to use this macro and each time applescripteditor tells me it has a syntax error (something about finding 'while' instead of something else).

Can someone help?

Thanks!
User avatar
loulesko
Posts: 124
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: Convert Hyperlinks to HTML

Post by loulesko »

bobmacatq wrote:Folks!

I'm trying to use this macro and each time applescripteditor tells me it has a syntax error (something about finding 'while' instead of something else).

Can someone help?

Thanks!
Hey there.
It's not an Apple Script it's Nisus Macro which you can install by checking our this link: http://nisus.com/forum/viewtopic.php?f=17&t=2097
bobmacatq
Posts: 13
Joined: 2011-01-14 17:49:49

Re: Convert Hyperlinks to HTML

Post by bobmacatq »

loulesko!

Thanks very much - don't know how I got the two confused!
Post Reply