How to reapply endnote style?

Everything related to our flagship word processor.
Post Reply
fgvs
Posts: 23
Joined: 2015-12-21 07:46:31

How to reapply endnote style?

Post by fgvs »

So I imported a document, applied NWP-defined styles to it. I want the endnote default text to be the note number number followed by a dot and a space, and have set the endnote style accordingly. This works for new endnotes, but the imported endnotes remain stubbornly bereft of any dot after the note number. My question is, how can I force the defined style to stick so as to get a dot after the number in every endnote in the document?

Thanks in advance for any clue.

Francisco
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: How to reapply endnote style?

Post by martin »

Hello Francisco:

What you described is expected, in that the "default note text" option only applies to freshly inserted footnotes/endnotes, and not any that were opened/imported from another document. For more on this, and a macro that will help you achieve the results you'd like, see this prior thread.

Please let me know if you have any questions at all.
fgvs
Posts: 23
Joined: 2015-12-21 07:46:31

Re: How to reapply endnote style?

Post by fgvs »

Brilliant, Martin, Thank you very much. I appreciate your prompt assistance, and am thrilled to realize that NWP includes a surprising bag of tricks.

Francisco
Þorvarður
Posts: 410
Joined: 2012-12-19 05:02:52

Re: How to reapply endnote style?

Post by Þorvarður »

Unfortunately there is an error on line 18 in the macro "Fix Note Default text" by Philip Spaelti.

The line

Code: Select all

$doc.text.deleteInRange $dummy.documentTextRange
triggers an error message. :(
User avatar
Hamid
Posts: 777
Joined: 2007-01-17 03:25:42

Re: How to reapply endnote style?

Post by Hamid »

Þorvarður wrote:Unfortunately there is an error on line 18 in the macro "Fix Note Default text" by Philip Spaelti.
[...]
I get the same error.
Try Kino's "Apply Default Note Text" macro; it works fine. You can download it from:
http://www2.odn.ne.jp/alt-quinon/files/ ... tendnotes/
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: How to reapply endnote style?

Post by phspaelti »

Þorvarður wrote:Unfortunately there is an error on line 18 in the macro "Fix Note Default text" by Philip Spaelti.

The line

Code: Select all

$doc.text.deleteInRange $dummy.documentTextRange
triggers an error message. :(
This vaguely rings a bell. The problem seems to be intermittent. It depends on some technical aspect of Nisus behavior creating footnotes, while running a macro, and when trying to test for the problem it often doesn't occur. Here is a changed version, that should no longer have that problem.

[macro removed]
Last edited by phspaelti on 2016-01-24 21:23:11, edited 1 time in total.
philip
Þorvarður
Posts: 410
Joined: 2012-12-19 05:02:52

Re: How to reapply endnote style?

Post by Þorvarður »

phspaelti wrote:Here is a changed version, that should no longer have that problem.
Hello Philip, Hamid et al.,

The new version now seems to have another error on line 32. The given character index is out of bounds for the Text object, and an additional empty footnote is inserted at the end of the text.
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: How to reapply endnote style?

Post by phspaelti »

Thanks for testing this, Þorvarður.

I'm really sorry about the piece of garbage I posted. I'm not quite sure how that previous macro ever made it this far. :oops:

The following version should (hopefully) actually work. One fundamental problem with footnote reference default text, is that once it is inserted it is just text. There is simply no sure way to tell default text from actual footnote text. The macro assumes that the default might be one or two (non-word) characters followed by white space. Reasonable choices would seem to be things like ". " or ") " or just space or tab. For things like that, the macro should now work.
Attachments
Fix Note Default text.nwm
(18.9 KiB) Downloaded 534 times
philip
Þorvarður
Posts: 410
Joined: 2012-12-19 05:02:52

Re: How to reapply endnote style?

Post by Þorvarður »

phspaelti wrote:the macro should now work.
Awesome. Thank you Philip. :D
drlaz
Posts: 7
Joined: 2009-09-22 19:26:22

Re: How to reapply endnote style?

Post by drlaz »

Thank you, just what I needed! Numbers came in after MS Word :x import with no following period. :)
User avatar
xiamenese
Posts: 543
Joined: 2006-12-08 00:46:44
Location: London or Exeter, UK

Re: How to reapply endnote style?

Post by xiamenese »

Hi, thank you all for contributions to this thread, and especially Philip for this macro, it finally gives me the complete suite of macros I need for turning output from Scrivener with footnotes into a fully styled document.

I do have one question, however: lines 23 & 24 contain the code

Code: Select all

# Check only footnotes
if $note.placement == "page"
which, if I read it rightly, means it will only work with footnotes. Some of my documents have endnotes rather than footnotes, though I haven't yet produced a document which has both. How would it be possible to modify it so that it would fix default note text for both footnotes and/or endnotes? Would it be as simple as removing those two lines and the associated 'end' instruction?

Thank you.

Mark
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: How to reapply endnote style?

Post by phspaelti »

xiamenese wrote:I do have one question, however: lines 23 & 24 contain the code

Code: Select all

# Check only footnotes
if $note.placement == "page"
which, if I read it rightly, means it will only work with footnotes. Some of my documents have endnotes rather than footnotes, though I haven't yet produced a document which has both. How would it be possible to modify it so that it would fix default note text for both footnotes and/or endnotes? Would it be as simple as removing those two lines and the associated 'end' instruction?
Hello Mark,
the answer to your question is no, it is not that simple. The macro works like this. First it inserts a "dummy" footnote at the end of the document. Then it retrieves the "default text" from that dummy and (tries to) enforce that all footnotes have that default text. If you were to remove the two lines (and the matching "end" line for the "if" statement), then the macro would enforce the same footnote default text on both footnotes and endnotes, This may be fine if you want this behavior, but it would be baffling if you tried the macro on a document with only endnotes. You would change the endnote default text, and all the endnotes would get the default text of the footnotes instead!

The proper fix should be for the macro to do the same thing for the endnotes that it does for the footnotes. The simplest solution would be to make a copy of the macro for endnotes and change the relevant bits (i.e., change "page" in line 24 to "document", and change the insertion of the "dummy" note from Footnote to Endnote (line 13):

Code: Select all

$dummy = Note.insertEndnoteInTextAtIndex $doc.text, $doc.text.length
After that you'll have a version of the macro that works for endnotes (but not footnotes).

A more clever solution would deal with both types of notes at the same time, but looking at the code now, I remember that there were some technical hurdles to get this to work correctly and so this would require some more elaborate testing.

And then finally there is the business about "section notes", which I understand to be endnotes placed at the end of each section. I assume that they are incompatible with regular endnotes, but I'm not sure how that works. There are no special commands for section notes, but the ".placement" property for such notes is "section".
philip
User avatar
xiamenese
Posts: 543
Joined: 2006-12-08 00:46:44
Location: London or Exeter, UK

Re: How to reapply endnote style?

Post by xiamenese »

Philip, thank you so much; as always you have been extremely generous with your time, knowledge and expertise.

I suspected as much, but thought I'd ask; you will appreciate that I am no programmer and although I try to read and understand the macros I encounter, the NWP macro language is very powerful and it is not easy for me to follow. I shall do as you say and create a variant macro for endnotes. When it comes to end-of-section notes, my need for these macros is to make the footnote or endnote text exported from Scrivener conform to the setting in my NWP styles. Since Scrivener has no way of marking sections during compile, it can only compile end-of-document notes. If I needed sections I would sort that out in NWP after running my main macro which sets proper styles and after running your endnote macro. I presume that modifying the style-sheet to put the notes at the end of their respective sections after that would then put them in the right place.

I'll play around with it.

Thank you.

Mark
Post Reply