Convert auto-numbered endnotes to "plain" notes

Everything related to our flagship word processor.
Post Reply
Talisman39
Posts: 21
Joined: 2003-04-26 13:37:00

Convert auto-numbered endnotes to "plain" notes

Post by Talisman39 »

I'm reviewing the manuscript guidelines for my publisher and one thing they are requesting is as follows:

"Do not use your word processing program's automatic footnote or endnote function. If notes are necessary, place them at the end of the chapter. Add note numbers manually in the text, using superscript numbers."

(And they want Word, but I'll put that off til the last possible moment!)

Obviously the end notes are going to stay fluid throughout writing (and I'm a long way off from submitting), and I'll be using a bibliography app (probably Sente) to manage stuff along the way.

Is there a way in Nisus to convert that automatic numbers into "regular" characters so I'm not having to manually re-type all this stuff once ready to format for submission?

Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Convert auto-numbered endnotes to "plain" notes

Post by Kino »

Does this macro work for you? It requires that chapters are separated by Section Break.

Copy the code below onto a new document and Macro => Save As Macro to save it under somewhere in your Macros folder. Or download it from
http://www2.odn.ne.jp/alt-quinon/files/ ... nd_nwm.zip

Due to a bug in NW‌ Pro 1.1, "Number Restart: Per Section" is not respected.
See http://www.nisus.com/forum/viewtopic.php?f=18&t=3116

Code: Select all

### Note2Body (section end) ###

# This macro creates a copy of the frontmost document,
# places note texts at the end of each section with
# note references converted into normal strings.

Require Application Version '3.1'

$doc = Document.active
if ! $doc.allNotes.count
	Exit 'No note found, exit...'
end

$newLine = Cast to String "\n"
$pageBreak = Cast to String "\x0C"

$doc = $doc.copy
$doc.clearAndDisableUndoHistory
$text = $doc.text
$noteKinds = Array.new 'footnotes', 'endnotes', 'sectionnotes'

$sections = Array.new
$index = 0
while $index < $text.length
	$range = $text.rangeOfSectionAtIndex $index
	$sections.appendValue $range
	$index = $range.bound
end

$notesPerSection = Hash.new
foreach $range in $sections
	$notesPerSection{$range} = Array.new
end

$allNotes = $doc.allNotes
foreach $note in $allNotes
	$range = $text.rangeOfSectionAtIndex $note.documentTextRange.location
	$notesPerSection{$range}.appendValue $note
end

foreach $range in reversed $sections
	$sectionEnd = $range.bound
	$notes = $notesPerSection{$range}
	if $notes.count
		$noteRefs = Array.new
		$noteTexts = Hash.new
		foreach $kind in $noteKinds
			$noteTexts{$kind} = Array.new
		end
		foreach $note in $notes
#			$range = $note.fullTextReferenceRange  # does not seem to work properly
			$range = Range.new $note.fullTextRange.location, $note.fullTextRange.length - $note.fullTextContentRange.length
			$noteText = $note.fullText.subtextInRange $range
			$noteText = Cast to String $noteText
			$noteRefs.appendValue $noteText
			$noteText &= $note.contentSubtext & $newLine
			if $note.placement == 'page'
				$noteTexts{'footnotes'}.appendValue $noteText
			elsif  $note.placement == 'document'
				$noteTexts{'endnotes'}.appendValue $noteText
			else
				$noteTexts{'sectionnotes'}.appendValue $noteText
			end
		end
		$notesInSection = ''
		foreach $kind in $noteKinds
			if $noteTexts{$kind}.count
				$notesInSection &= $newLine & "[$kind]"
				$notesInSection &= $newLine
				$notesInSection &= $noteTexts{$kind}.join ''
			end
		end
		$text.insertAtIndex $sectionEnd, $notesInSection
		foreach $note in reversed $notes
			$range = $note.documentTextRange
			$note.documentText.replaceInRange $range, $noteRefs.pop
		end
	end
end

### end of macro ###
And this one does the same except that all note texts will be put at the end of the document.
http://www2.odn.ne.jp/alt-quinon/files/ ... nd_nwm.zip

Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Convert auto-numbered endnotes to "plain" notes

Post by Kino »

If you want to make endnote number restart "per section" in the current version of NW‌ Pro...

1. Comment out or remove the following command:

Code: Select all

$doc = $doc.copy
2. Duplicate your document by saving it as a different name or in a different folder.

3. In the copy of the document just created, switch to Style Sheet and set "Number Restart" of Endnote style to "Per Section".

4. Switch back to Page or Draft View and run the macro on it.

Talisman39
Posts: 21
Joined: 2003-04-26 13:37:00

Re: Convert auto-numbered endnotes to "plain" notes

Post by Talisman39 »

Perfect! Thanks

Post Reply