Reply to topic  [ 4 posts ] 
Making and index of first lines? 
Author Message

Joined: 2010-09-18 12:24:52
Posts: 27
Is there a way to generate an index of first lines of paragraphs for a document? And then click on a line and go to that line? I seem to remember something like this long ago in Nisus.


2017-04-26 11:26:05
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
How about adding bookmark to all the first lines of paragraph? The macro below will do the job.
Code:
### Bookmark First Lines ###

Require Pro Version '2.1'

$prefix = @S'_'

/*
 • $prefix above defined will make it easier to distinguish bookmarks added by this macro from other bookmarks.
 • If your document has not other bookmarks, use @S'' which will add nothing to bookmark names.
*/

$doc = Document.active
if $doc == @undefined
   exit 'No open document, exiting...'
end

$paragraphStarts = $doc.text.findAll '^(?=\S)', 'E-i'
   # Get the location of paragraph starts followed by a visible character.

if $paragraphStarts.count > 0
   foreach $start in $paragraphStarts
      $firstLine = TextSelection.new($start.text, $start.text.rangeOfLineAtIndex($start.location))
      # Get TextSelection object for this paragraph start.
      $bookmarkName = $prefix & $firstLine.substring
      Push Target Selection $firstLine
         Add Bookmark As $bookmarkName
      Pop Target Selection
   end
end

Set Navigator Mode 'Bookmarks by Location'
Set Navigator Shown @true

### end of macro
Attachment:
File comment: macro file
BookmarkFirstLines_20170427_nwm.zip [4.81 KiB]
Downloaded 40 times


2017-04-26 12:36:43
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
editor10 wrote:
I seem to remember something like this long ago in Nisus.
I just had an idea. Macro is not necessary. Switch to the Style sheet and add a TOC level to the paragraph style for normal text. First portion of every paragraph in that style will show up in the Navigator.


2017-04-27 02:44:58
Profile

Joined: 2010-09-18 12:24:52
Posts: 27
Kino,

Thank you very much. The macro didn't work for me but the TOC style method is perfect.


2017-04-27 11:07:55
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: Google [Bot] and 7 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