Join macro: tables destroy 'Normal' style

Everything related to our flagship word processor.
Post Reply
ThosGreen
Posts: 16
Joined: 2021-09-15 03:28:09

Join macro: tables destroy 'Normal' style

Post by ThosGreen »

I started this as a reply in the thread 'Merging files into one document' but here's a new thread because I now know more precisely what's happening.

Suppose two or more files are concatenated using the Join macro, and at least one file contains a Nisus table. In the resulting joined file, all paragraphs that previously used the style 'Normal' will have either no style applied, or else a style named '43510' or some other inexplicable number. That apparently applies to all instances of Normal-style paragraphs, whether they come before or after the Nisus table. No other styles seem to affected.

The styles that are affected revert back to what I suppose is a basic Nisus style, with line spacing set to 1 line and space/after set to zero. (That's not the default style I use.)

Does anyone understand this bug or can suggest how to fix it?

A conjecture: if I replace all Normal style paragraphs (before using the Join macro) with a style called say NormalSafe, with identical formatting to Normal, perhaps all will be well. That would suggest that it's the style at the top of the style hierarchy that gets damaged.
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Join macro: tables destroy 'Normal' style

Post by phspaelti »

I just tried replicating this and it is exactly as you say. Specifically I created 3 files
  • File A with a Heading 1 paragraph two Normal paragraphs and a Table
  • File B with a Heading 1 and a Normal paragraph
  • File C with a Heading 1 and a Normal paragraph
If I join B and C everything is fine.
If I join A and B everything is fine, except the Normal paragraphs have no applied Paragraph style.

I looked at Kino's old macro and it has a mess of (unnecessary) styles in it. I deleted almost all of them, but this had no effect. This didn't surprise me, as nothing in the macro would seem to affect styles, and there is certainly nothing that would explain the difference between joining files with and without tables.
So my guess is that this would be a bug in Nisus itself, perhaps the Macro language component? Maybe the .join command? The macro does put all the text objects of the open files into an array, and then uses .join to create a single text object.
philip
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Join macro: tables destroy 'Normal' style

Post by phspaelti »

On further testing, I think the .join command may really be the culprit. .join performs some interesting style conflict resolution. For example i renamed one of the Normal styles, and even though both Heading 1 styles were now based on divergent "Normal" styles they simply get merged back together again, and the first "Normal" style carried the day. Meanwhile the one still named "Normal" was not applied (but it's attributes were preserved.
philip
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Join macro: tables destroy 'Normal' style

Post by martin »

I also see something strange going on here with regard to resolving the final set of styles in the presence of a table. I'll have to file this bug for further investigation.

In the meantime I'm attaching a revised macro that should do what you want. It avoids the problem with the "join" command completely. Instead it outright clones the first document in the join list, ensuring it's used as a basis for styles/etc.
Attachments
JoinFiles_2022-05.zip
(5.18 KiB) Downloaded 135 times
Post Reply