
I have been looking into my macros, as the one I have always used is highly complex and is beginning to prove slightly ineffective — it was created for Scrivener v. 2, which didn't have styles. What I want macros to do is work on an RTF compiled from Scrivener:
- import a style sheet to replace the existing styles in the document — although NWP picks up the styles from Scrivener, they are not cascading, which makes it more difficult to make global changes;
- language mark all text in Chinese as "Chinese" rather than "English"
- regularise Footnote and Endnote styles to conform with the styles in the NWP style sheet;
For (1) I have tried the snippet of code
Code: Select all
$editDoc = Document.active
$filePath = "~/Dropbox/nisus/Nisus Writer Settings/Style Library/Case report.rtf"
$styleLibDoc = Document.open $filePath
$editDoc.addStyles $styleLibDoc.allStyles, "replace"
$styleLibDoc.close
For (2) I have the macro that Martin crafted for me years ago, and that works well.
With (3) I have 3 problems:
- The macro I have to regularise footnotes—by Philip, no less, modified by him in 2016!— returns an error in line 26: "The given character index (1) is out of bounds for the Text object (length 0)".
- The macro I have to regularise endnotes—again courtesy of Philip in 2016— runs but makes 0 changes in a document with 50+ endnotes, even though they do not match the imported NWP style definition.
- The macro to regularise the note numbers in the text, whatever I had no longer works for some reason. When I run the macro to import styles, although the footnote marker in the text is defined as '9pt Adobe Garamond Pro raised 2pts', it applies the raised baseline but leaves the font size as 11pt. I've tried using a Search and Replace which I macroized to replace the '11pt raised 2pts' that I get to the '9pt raised 2pts' that I want. What I have is:
Where the <\d> is styled '11pt Adobe Garamond Pro raised 2pts' and the <\0> is styled '9pt Adobe Garamond Pro raised 2pts'. It only finds one occurrence, where the footnote number is preceded by a lower case 'L'! This is the case whether it runs as a macro or from the "Search and Replace" dialog.
Code: Select all
Find and Replace @Text<\p{Lower}\d>, @Text<\0>, 'EauU'
If I don't run the set styles macro first, the compiled RTF has in-text footnote markers as 11pt superscript, which is too small in my view, hence wanting to change it to 9pt raised 2pts — my default text size is 11pts. So a macro, which would be font and regular, italic or bold variant agnostic to solve that would be equally as useful.

Mark
Edit to attach compiled RTF file and NWP stylesheet. Seems 3 is the limit on attachments; RTF text in a new post.