How to reapply endnote style?
How to reapply endnote style?
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
Thanks in advance for any clue.
Francisco
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: How to reapply endnote style?
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.
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.
Re: How to reapply endnote style?
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
Francisco
Re: How to reapply endnote style?
Unfortunately there is an error on line 18 in the macro "Fix Note Default text" by Philip Spaelti.
The line
triggers an error message. 
The line
Code: Select all
$doc.text.deleteInRange $dummy.documentTextRange

Re: How to reapply endnote style?
[...]Þ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/
Re: How to reapply endnote style?
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.Þorvarður wrote:Unfortunately there is an error on line 18 in the macro "Fix Note Default text" by Philip Spaelti.
The linetriggers an error message.Code: Select all
$doc.text.deleteInRange $dummy.documentTextRange
[macro removed]
Last edited by phspaelti on 2016-01-24 21:23:11, edited 1 time in total.
philip
Re: How to reapply endnote style?
Hello Philip, Hamid et al.,phspaelti wrote:Here is a changed version, that should no longer have that problem.
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.
Re: How to reapply endnote style?
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.
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.
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.

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 773 times
philip
Re: How to reapply endnote style?
Awesome. Thank you Philip.phspaelti wrote:the macro should now work.

Re: How to reapply endnote style?
Thank you, just what I needed! Numbers came in after MS Word
import with no following period. 


Re: How to reapply endnote style?
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
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
I do have one question, however: lines 23 & 24 contain the code
Code: Select all
# Check only footnotes
if $note.placement == "page"
Thank you.
Mark
Re: How to reapply endnote style?
Hello Mark,xiamenese wrote:I do have one question, however: lines 23 & 24 contain the code
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?Code: Select all
# Check only footnotes if $note.placement == "page"
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
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
Re: How to reapply endnote style?
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
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