Reply to topic  [ 3 posts ] 
From plain text to notes? 
Author Message

Joined: 2007-11-09 15:27:25
Posts: 86
I’m experimenting with writing in ‘plain text’—by which I mean using in-text code for formatting. This is easy for character formatting, and even for Paragraph formatting, since macros can turn this ‘code’ into real formatting in Nisus. But what about footnotes?
I know I can use Ulysses to make the transformation, but it seems that it should be trivial for Nisus to do the same.

So, if I have a note reference as in this example:

The existential and veridical uses of the verb rely equally on a consistent price for spinach.{{FN1}}

And a note—say at the end of the document—like this:

{{FN1-Text of note. Spinach?}}

How might this be turned into a real note with reference?
http://nisus.com/forum/viewtopic.php?f=17&t=2745&hilit=footnote has a macro to do this, but it doesn’t quite work for me. Perhaps because NW has been updated since?


2009-12-28 12:56:29
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
Each macro for that purpose assumes a special format of in-text notes. Your format is somewhat similar to the one supported by a macro I wrote for formatting an e-text.
Code:
$sep = Cast to String ".\xA0"  # characters between the note reference and the note text

Require Pro Version 1.2
$doc = Document.active
if $doc == undefined
   exit
end
$text = $doc.text

Find All '(?:^\d+\.\x20)+\p{Any}+?\n\Z', 'E'
$fnTextNum = Find All in Selection '(?<=^\d\.\x20|^\d\d\.\x20)\p{Any}+?(?=\n\d+\.|\n\Z)', 'E-i'
if ! $fnTextNum
   exit 'Nothing found, exit...'
end
$fnText = $doc.selectedSubtexts

$fnRefNum = Find All '\(\d+\)', 'E'
if ! $fnRefNum
   exit 'Nothing found, exit...'
end

$fnRef = $doc.textSelections
$i = $fnRef.count - 1

while $i >= 0
   $attr = $text.displayAttributesAtIndex $fnRef[$i].location
   if $attr.superscript != 1
      $fnRef.removeValueAtIndex $i
   end
   $i -= 1
end

if $fnRef.count != $fnText.count
   exit 'The number of note ref is different from that of note text, exit...'
end

Select Start

$offset = 0
foreach $ref in $fnRef
   $lenPrec = $text.length
   $range = $ref.range
   $range.location += $offset
   $text.deleteInRange $range
   $noteText = $sep & $fnText.dequeue
   Note.insertFootnoteInTextAtIndex $text, $range.location, $noteText
   $offset += $text.length - $lenPrec
end
You can see how the macro above works by running it on the following html file opened in NWP.
http://socserv.mcmaster.ca/econ/ugcm/3ll3/hume/treatise1.html

While this kind of in-text footnotes is inevitalbe for web pages, it would not be a good idea to adopt it for writing your own documents because it would not be easy for you to keep the correspondance between note symbols ({{FN1}} in your example) and note texts ({{FN1-Text of note. Spinach?}}). You will have to update note numbers each time you add a new note between existing notes.

So I think it would be better to use in-line notes like this.

The existential and veridical uses of the verb rely equally on a consistent price for spinach.{{Text of note. Spinach?}}

For that kind of in-line notes, you can use the following macros to converts them into NWP’s footnotes/endnotes and vice versa.
http://www2.odn.ne.jp/alt-quinon/files/NWPro/footendnotes/Body2Note_nwm.zip
http://www2.odn.ne.jp/alt-quinon/files/NWPro/footendnotes/Note2Body_nwm.zip
Those macros assume LaTeX style in-line notes: \footnote{note text} but you can customize them easily so that they support, for example, {{note text}}.


2009-12-28 18:23:55
Profile

Joined: 2007-11-09 15:27:25
Posts: 86
Thank you, Kino. This is quite helpful.
You’re right, of course, that I’d need to use your second solution, which works fine, as long as notes are not long. For me, anyway, long notes interrupting a text make for ugliness, and I often have long notes.

What I was hoping to be able to do is:
Keep notes and text separate and ‘merge’ them only for final output. Perhaps I’ll have to stick with Ulysses to do this.

(By the way, my interest in doing this comes from having lost footnotes in the past—when switching from NWClassic to OSX. I now see the value of plain text, especially as I am in the midst of reconstituting something written with NWClassic.)


2009-12-29 08:16:26
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software