Subject: | |
From: | |
Reply To: | |
Date: | Thu, 23 Dec 2010 20:30:11 +0900 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
For some reasons, I'm now using hyperlinks to index a document. It is very nice that NWP does not check for the format of destination link ;-) One of the reasons is that it is difficult to verify topic and sub-topic applied on texts. Well, you have the Indexing palette which, however, does not allow you to see them all at once. Neither can you write a macro for such a purpose because NWP does not have a macro command which returns topic and sub-topic for a given character index. For hyperlink, such a command is available.
So here is a macro which will insert destination text after each text portion having a link. E.g. "Apple" having a url link will be "Apple [http://www.apple.com/]".
<http://www2.odn.ne.jp/alt-quinon/files/NWPro/link/MakeLinkVisible_nwm.zip>
Some additional macros:
<http://www2.odn.ne.jp/alt-quinon/files/NWPro/link/MakeLinkIndex_nwm.zip>
<http://www2.odn.ne.jp/alt-quinon/files/NWPro/link/ClearAllLinks_nwm.zip>
Have nice holidays,
Kino
As to Italian cinema, I was deeply impressed by Ettore Scola's "Una Giornata particolare".
--
### Make Link Index ###
# Insert link destination text after each link with $prefix and $suffix, e.g.
# Language of the current insertion point will be applied on texts to be inserted.
$prefix = Cast to String ' ['
$suffix = Cast to String ']'
$highLightColor = Color.newWithRGB255 234, 235, 255
$doc = Document.active
if $doc == undefined
exit
end
$selActive = TextSelection.active
$attr = $selActive.text.displayAttributesAtIndex $selActive.location
$lang = $attr.language
$sels = Array.new
foreach $text in $doc.allTexts
$i = 0
while $i < $text.length
$attr = $text.attributesAtIndex $i
$range = $text.rangeOfAttributesAtIndex $i
if Defined $attr.link
$sel = TextSelection.new $text, $range
$isContinuous = false
if $sels.count
if $sels.lastValue.bound == $sel.location
if $sels.lastValue.text.isSameObject $text
$sels.lastValue.length += $sel.length
$isContinuous = true
end
end
end
if $isContinuous == false
$sels.appendValue $sel
end
end
$i = $range.bound
end
end
if ! $sels.count
exit 'No link found, exiting...'
end
foreach $sel in reversed $sels
$attr = $sel.text.attributesAtIndex $sel.location
$linkText = $prefix & $attr.link
$linkText &= $suffix
Push Target Text $linkText
$lang.apply
Set Highlight Color $highLightColor
Pop Target Text
$sel.text.insertAtIndex $sel.bound, $linkText
end
### end of macro ###
|
|
|