Cleaning up punctuation triggers but?

Get help using and writing Nisus Writer Pro macros.
Post Reply
Groucho
Posts: 497
Joined: 2007-03-03 09:55:06
Location: Europe

Cleaning up punctuation triggers but?

Post by Groucho »

For years I have used a modified version of the Cleaning up Punctuation macro that comes with NWP. From v. 2.0.4 on I noticed a strange behavior caused by an apparent bug in line 11 (of the original version.) The line runs thus:

Code: Select all

Find and Replace ‘\s*([,.;:\!\?])‘, ‘\1’, ‘aE’
I think that \s* should rather be \s+, but this is not the point. The point is that, given a condition, this macro triggers a (supposed) bug. Take this excerpt, for example:
It is possible to distinguish two main types of reaction among those who conceded his central argument. In the first place, there were those who thought that the loss of efficiency, the decline in general wealth that will be the effect of the absence of a means of rational calculation, would not be too high a price for the realization of a more just distribution of this wealth. Of course, if this attitude is based on a clear realization of what this choice implies, there is no more to be said about it, except that it seems doubtful whether those who maintain it would find many who would agree with their idea.
The real difficulty here is, of course, that for most people the decision on this point will depend on the extent to which the impossibility of rational calculation would lead to a reduction of output in a centrally directed economy compared with that of a competitive system. Although in the opinion of the present writer it seems that careful study can leave no doubt about the enormous magnitude of that difference, it must be admitted that there is no simple way to prove how great that difference would be. The answer here cannot be derived from general considerations but will have to be based on a careful comparative study of the working of the two alternative systems and presupposes a much greater knowledge of the problems involved than can possibly be acquired in any other way but by a systematic study of economics.
Two parts of the text have been italicized. Each ends with a punctuation mark.
This is the outcome upon running the macro:
It is possible to distinguish two main types of reaction among those who conceded his central argument. In the first place, there were those who thought that the loss of efficiency, the decline in general wealth that will be the effect of the absence of a means of rational calculation, would not be too high a price for the realization of a more just distribution of this wealth. Of course, if this attitude is based on a clear realization of what this choice implies, there is no more to be said about it, except that it seems doubtful whether those who maintain it would find many who would agree with their idea.
The real difficulty here is, of course, that for most people the decision on this point will depend on the extent to which the impossibility of rational calculation would lead to a reduction of output in a centrally directed economy compared with that of a competitive system. Although in the opinion of the present writer it seems that careful study can leave no doubt about the enormous magnitude of that difference, it must be admitted that there is no simple way to prove how great that difference would be. The answer here cannot be derived from general considerations but will have to be based on a careful comparative study of the working of the two alternative systems and presupposes a much greater knowledge of the problems involved than can possibly be acquired in any other way but by a systematic study of economics.
As you can see, the italicized text has been expanded. There are italicized parts that were previously plain. This is true with bold too, whether superimposed or enforced through a style.
In its unmodified form, the macro selects any punctuation mark, preceded or not preceded by white space, and changes the selection into the punctuation mark alone. Changing line 11 into this:

Code: Select all

Find and Replace ‘\s+([,.;:\!\?])‘, ‘\1’, ‘aE’
the macro works OK. So \s* seems to be the culprit.

Best regards, Henry.
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Cleaning up punctuation triggers but?

Post by martin »

Hi Henry- from what you describe that sounds like a bug, but I haven't been able to reproduce it. I'm thinking that could have something to do with the formatting in your actual document, as compared to the formatting I get when I copy-paste content from Safari. Would you be able to post your sample text snippet as a NWP document? Or you could send it to me via the menu Help > Send Feedback if you prefer.

Thanks for your help!
Groucho
Posts: 497
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Cleaning up punctuation triggers but?

Post by Groucho »

Here it is, along with the original NWP macro. I ran the macro on it minutes ago and the result is always the same.

Note that, though I use a modified version of the macro, I left line 11 quite intact. I only substituted \s+ for \s* when I realized it was causing the glitch. Also, \s* uselessly forces the macro to search for a punctuation mark preceded or not preceded by white space. \s+ works OK.

Greetings, Henry.
Archive.zip
(6.75 KiB) Downloaded 748 times
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Cleaning up punctuation triggers but?

Post by martin »

Thank you for the sample file Henry- with it I've been able to reproduce the unwanted spreading of formatting. This is definitely some kind of bug in the find/replace command, and we'll take a look at getting it fixed. Thanks again.
Groucho
Posts: 497
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Cleaning up punctuation triggers but?

Post by Groucho »

Thank you

Henry.
Post Reply