Reply to topic  [ 6 posts ] 
Convert Hyperlinks to HTML 
Author Message
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
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 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.



2011-04-21 19:10:07
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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:
#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.


2011-04-22 15:54:20
Profile WWW
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
Hi Martin,

Gotchya. Thanks for pointing that out. Much appreciated.

I edited the macro above.

Lou


2011-04-22 22:52:13
Profile WWW

Joined: 2011-01-14 17:49:49
Posts: 13
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!


2011-04-24 17:49:30
Profile
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
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


2011-04-24 21:54:51
Profile WWW

Joined: 2011-01-14 17:49:49
Posts: 13
loulesko!

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


2011-04-25 05:23:23
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software