NISUS Archives

July 2012

NISUS@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Philip Spaelti <[log in to unmask]>
Reply To:
Date:
Sun, 22 Jul 2012 02:46:59 +0900
Content-Type:
multipart/alternative
Parts/Attachments:
text/plain (3588 bytes) multipart/related (3588 bytes) , text/html (5 kB) , icon-small.gif (5 kB)
Hello again Žorvaršur

as I was suspecting there is actually a macro to do this kind of thing in the Nisus Macro Repository
called:
"	Convert Notes to Inline Snippets (and vice versa)"


That macro works with inline tagged notes (such as used in TeX). So the text of the footnote would be at the exact location of the reference in the text in a form like {\fn ... } or something like that. The repository macro is fairly elaborate.

NWP macro language actually has a fairly straightforward command to do this kind of thing:

Note.insertFootnoteInTextAtIndex( $text, $index, $noteContent )

I have tried writing a very bare-bones macro for my purposes. I am working with a scanned and OCRed document, so the footnotes are at the bottom of the page. The following is my *in-progress* (alpha, not beta) macro:

### start of macro

$doc = Document.active
$docText = $doc.text

Find All '^[[:digit:]]+\) [^\n\f]+', 'Eau'

$notes = $doc.selectedSubtexts

$noteList = Hash.new
foreach $note in $notes
	$note.find '^(?<num>[[:digit:]]+)(?<content>\) [^\n\f]+)’, ‘E$’
	$noteList{$num} = $content
end

Select Document Start
While Find Next "[[:digit:]]+", 'Eu'
	$markerSel = TextSelection.active
	$markerNum = $markerSel.substring
	Delete
	Note.insertFootnoteInTextAtIndex($docText, $markerSel.location, $noteList{$markerNum})
end

### end of macro

This macro identifies the footnotes and the reference markers using styles, and the find expressions will need the styles applied for this to work properly. Alternately one could change the expression to something that unambiguously identifies the relevant text.

If the notes are in a separate file, one would simply switch documents after collecting the note contents from the first document.

Hope this helps
Philip


On 19. Jul 2012, at 16:38 , Žorvaršur Davķšsson wrote:

> On 18.07.2012, at 03:14, Philip Spaelti wrote:
> 
>>> 
>>> I have quite a few documents with endnotes, but the links between the endnote markers and the notes are broken and have to be fixed. Is there any way to do this automatically using a macro?
>> 
>> I would say yes. It depends a bit on the configuration you have.
> 
> That’s good to hear and that gives me courage to carry on. I’m not exactly sure though what you mean by configuration. The endnote number (= the note’s marker location in the document) and the form/style of note references (at the end of the document) can be easily altered before the macro is run in order to make them accessable for the macro.
> 
> 
>>> Here is an example document (with endnote markers and notes):
>>> 
>>> http://minus.com/mm5Wh0xYO/1f
>>> 
>> 
>> By the way this is only a png, right? One would have to have the actual file to determine whether it's possible in your case.
> 
> 
> Yes, this is only a png to demonstrate what I was trying to say. Many of these documents are novels downloaded from Project Gutenberg or reviews from online magazines. 
> 
> 
>> Assuming you had two files, one with the text and the foot/endnote locations marked and numbered, and the second with the text of the notes correctly numbered, you could certainly write a macro to turn those into proper notes.
> 
> Two files? That sounds interesting. I hadn’t thought of that. Maybe that makes it easier. Thanks for the suggestion.
> 
>> (A macro like that has been on my to do list for some time. But notes are generally such a low priority for me…)
> 
> I will keep my eye on the ball and let the list know if I can come up with something useful. 
> 
> 
> Best wishes,
> Žorvaršur

Philip Spaelti
[log in to unmask]







ATOM RSS1 RSS2