Page 1 of 1

Convert Hyperlinks to HTML

Posted: 2011-04-21 19:10:07
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

Re: Convert Hyperlinks to HTML

Posted: 2011-04-22 15:54:20
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.

Re: Convert Hyperlinks to HTML

Posted: 2011-04-22 22:52:13
by loulesko
Hi Martin,

Gotchya. Thanks for pointing that out. Much appreciated.

I edited the macro above.

Lou

Re: Convert Hyperlinks to HTML

Posted: 2011-04-24 17:49:30
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!

Re: Convert Hyperlinks to HTML

Posted: 2011-04-24 21:54:51
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

Re: Convert Hyperlinks to HTML

Posted: 2011-04-25 05:23:23
by bobmacatq
loulesko!

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