A “Convert Text to Notes.nwm” macro?

Get help using and writing Nisus Writer Pro macros.
lellius
Posts: 54
Joined: 2002-08-15 22:06:44

A “Convert Text to Notes.nwm” macro?

Post by lellius »

To manage long documents with two thousands and more footnotes I find very useful the powerfur macro “Convert Notes to Text.nwm” provided by Nisus Pro. Thus, inline in the body text, I can do easily multiple changes to notes which however are rather hard to be accomplished when working in the the note text itself (by the two thousands and more footnotes!!!).
Then, Inline in the body, the note’s text appears delimited by (( )), with a superscripted number.
like this example:
Even if the search is in the right neighborhood, remember that they are scouring this enormous area in aircraft and in boats looking for debris that could be no larger than about 60 feet long and 20 feet wide.((1 More likely, such debris will be even smaller.)) The searchers are seeking these physical clues mostly with the naked eye and within an area littered with many millions of pieces of floating debris, much of it not much different looking than the pieces of wreckage.((2 that we would expect in the crash of a large transport airplane in the open ocean.))
-----
((1 ; ((2 above: the numbers 1 and 2 should appear superscript
-----
Up to now I didn’t yet found a macro which can perform the reverse move, to convert those texts - delimited by (( )) - in continuing footnotes with their proper reference numbers.
Can anyone help me?
Thanks
gb
Attachments
Exanple.rtf
(7.42 KiB) Downloaded 1162 times
lellius
Posts: 54
Joined: 2002-08-15 22:06:44

Re: A “Convert Text to Notes.nwm” macro?

Post by lellius »

Unfortunately it doesn't work. I tried all the proposed options (by Kino), but none of them works or perhaps I am not able to use them.
What I need is a macro which runs on selected text or the whole text of the document and does this task:
1. cuts the text from inside the note’s tags: “((” - “))” respectively in my case, or changed to “{{” - “}}”, if necessary
2. inserts a new footnote or endnote (option)
3. Paste the above cut text
and so repeatedly over a selected text or the whole document.
Important the macro instructions does select exactly the text delimited by the tags, step by step, without springing to the next note.

An example is given in the attached file
Thanks
gb
Attachments
Example.rtf
(8.88 KiB) Downloaded 1149 times
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: A “Convert Text to Notes.nwm” macro?

Post by phspaelti »

I find it strange that such a macro is not already provided. (Hey Martin, what happened?)
Well here a version that does the things you asked for.
Convert Text to Notes.nwm
(17.03 KiB) Downloaded 1227 times
A few comments.
  • Part of the problem with this kind of macro is that one has to rely on the notes being of the correct form. (I guess that's the point of that discussion by Kino in the other thread.)
  • The convert note to text macro allows you to customise the delimiters. I didn't do that here, because it's too much of a hassle. (Whoever chose double-parentheses as the default deserves to be shot! :P )
  • The other macro allows you to put the text notes at the end. This macro would not convert those kinds of notes back correctly. To do that you need a different kind of macro that can find the references in the text and link them back correctly
philip
jb
Posts: 92
Joined: 2007-11-09 15:27:25

Re: A “Convert Text to Notes.nwm” macro?

Post by jb »

Hi,
It works for me so I’m not sure what problem you’re having.
Did you define the opening and closing delimiters in the text of the macro?
You can define them to be pretty much anything you like.

In your case, edit the text of the macro at the beginning to look like this:

$prefix{'footnotes'} = '(('
$suffix{'footnotes'} = '))'

If you then have in your text something like this

Fu eletto vescovo di Lodi.((Cipolla, pp. 15s.))

When you run the macro, what’s inside the delimiters will appear as the text of a footnote, and this will work for all of the instances it encounters and will number them appropriately. It works fine for me. Superscript numbers will be treated like any other text, so if you want them gone you’d need to remove them yourself. Probably a simple Find/Replace would work fine.

As far as I know this macro runs on the entire file. So you’d need to copy/paste the material you want to convert into a new document if you don’t want to convert in-text notes to footnotes.

I hope this works for you.

jb
lellius
Posts: 54
Joined: 2002-08-15 22:06:44

Re: A “Convert Text to Notes.nwm” macro?

Post by lellius »

Philip,
Great! it's working, just I wanted, in selection
Thank very much
gb
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: A “Convert Text to Notes.nwm” macro?

Post by phspaelti »

Well, I'm glad it suits your needs, but after reviewing jb's comment and Kino's macro, it occurred to me that my macro will have one drawback in that it will not allow the notes to span paragraphs, that is it won't work right if the note contains a paragraph marker. If that is a problem for you, the macro will need to be modified a bit.

Update: so here now a slightly modified version, that will work across a return.
Convert Text to Notes.nwm
(17.09 KiB) Downloaded 1214 times
philip
jb
Posts: 92
Joined: 2007-11-09 15:27:25

Re: A “Convert Text to Notes.nwm” macro?

Post by jb »

Hi,
This macro (Convert Text to Notes) isn’t working for me.
Maybe due to updates to Nisus?
On a short text with two footnotes, I run the macro (supplied by Nisus) “Convert Notes to Text”.
Then I run the macro supplied by Philip, which I expect to effectively “undo” the previous macro.
Instead I get this error message:

Code: Select all

There was an error on line 14...
The “length” property requires an object, instead found “undefined” from “$noteRefNum”
Any suggestions?
Thanks
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: A “Convert Text to Notes.nwm” macro?

Post by phspaelti »

jb wrote:Then I run the macro supplied by Philip, which I expect to effectively “undo” the previous macro.
Instead I get this error message:

Code: Select all

There was an error on line 14...
The “length” property requires an object, instead found “undefined” from “$noteRefNum”
Any suggestions?
Hmm… I don't get the same message. But I get a different one. (The 2.1. update did make some minor adjustments to the macro syntax.)

Here's my modified version:
Attachments
Convert Text to Notes.nwm
(17.05 KiB) Downloaded 1017 times
philip
jb
Posts: 92
Joined: 2007-11-09 15:27:25

Re: A “Convert Text to Notes.nwm” macro?

Post by jb »

Edited:

This does in fact work.
I read the macro and realized that it requires that the text be selected.

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

Re: A “Convert Text to Notes.nwm” macro?

Post by phspaelti »

Yeah, it's not the most user-friendly macro. It's very specific to the relevant conditions, and it doesn't check properly to see if the conditions are met.
That's a general problem with macros/software. if you want to write software that works reliably, about 80~90% of your time will be spent on user-interface and documentation, and only 10~20% on getting it to work right. I—and, I suspect, most macro writers—are only really interested in the latter, and it's usually not worth my time to make a macro "fool-proof".
philip
jb
Posts: 92
Joined: 2007-11-09 15:27:25

Re: A “Convert Text to Notes.nwm” macro?

Post by jb »

Indeed.
I've already made it my own by removing the 'In Selection' requirement and changing the delimiters. (Those double parentheses are just asking for trouble. I know those weren't your idea, Philip.;-))

Such pitfalls and all, macros are one reason I think Nisus is the champion.

Thank you for making it possible for people like me to take advantage of this great feature.
jb
Posts: 92
Joined: 2007-11-09 15:27:25

Re: A “Convert Text to Notes.nwm” macro?

Post by jb »

Probably of no interest to anyone but me:

I’ve been using the reincarnation of Ulysses lately (Ulysses 3)—a plain text/markdown editor with footnotes (among other things). It’s easy to get styled and footnoted text from Ulysses to Nisus, but not so easy the other way. So I tinkered with the macro “Convert Notes to Text” (supplied by Nisus) and managed to get it to turn NIsus footnotes into a plain text markdown format that Ulysses can import. Turning italics into markdown syntax (*italics*) is trivial in Nisus, of course. So for me, because all I need are simple headings, italics, and footnotes, this macro allows me to move texts back and forth.
lellius
Posts: 54
Joined: 2002-08-15 22:06:44

Re: A “Convert Text to Notes.nwm” macro?

Post by lellius »

Philip,
please your macro “Convert Text to Notes.nwm” doesn't work properly (I have Nisus 2.1.10 and macOS Mojave).
I tried both, preserving and removing the 'In Selection' requirement and changing the delimiters — i prefer [[ ]] as delimiters. But nothing happened.
The reverse macro “Convert Notes to Text.nwm” works well, also it does save the note reference number.
The problem or one problem by macro “Convert Text to Notes.nwm” seems to be the “lenght” property on line 14.
I got always this answer:

There was an error on line 14...
The “length” property requires an object, instead found “undefined” from “$noteRefNum”.

Have you or has anyone any solution?
Thanks
lellius
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: A “Convert Text to Notes.nwm” macro?

Post by phspaelti »

Hello lellius,
I'm sorry you are having trouble with this. As the (age old) discussion above alludes to, this macro is rather delicate. I am trying yet another fix. The current version now has the delimiters changed to double brackets. I hope this helps. If it still doesn't work, just write again.
Convert Text to Notes.nwm
v. 2018/10/22
(19.42 KiB) Downloaded 994 times
philip
Post Reply