transforming paragraph style to pagebreak

Get help using and writing Nisus Writer Pro macros.
Post Reply
janklug
Posts: 8
Joined: 2014-05-09 11:21:13

transforming paragraph style to pagebreak

Post by janklug » 2014-05-11 03:36:39

Hey,

I'm having some problems with my workflow: writing in Scrivener, exporting as .fodt, finishing up in Nisus Writer Pro.
One of the issues is that pagebreaks in Scrivener are translated to a paragraph style containing a horizontal line in Nisus Writer (happens because the .fodt export assumes that pagebreaks are not necessary for webpages..)

Anyway, I was hoping to be able to write a macro that 1) finds all the occurrences of the paragraph style called 'Horizontal Line', and 2) replaces these with a pagebreak...
Unfortunately, I'm just getting started with macros, and my time until submission deadline shrinks, so I was wondering if anybody had a tip to help me getting started!

Thanks,

Jan

User avatar
phspaelti
Posts: 956
Joined: 2007-02-07 00:58:12
Location: Japan

Re: transforming paragraph style to pagebreak

Post by phspaelti » 2014-05-12 04:52:35

The quickest way to do this is not with a macro at all. Use "Find and Replace".
  1. Open the Find dialog
  2. In the Find box enter either (a) "Special characters > Return" or (b) "Special positions > End of Paragraph" depending on the desired result
  3. Apply the "Horizontal Line" style to the Find box. Make sure "Attribute sensitive" is now clicked.
  4. Move to the Replace box. Enter a page break.
  5. Do "Replace All"
If you want, you can use "Macroize" to save this as a macro, for later reuse.
philip

janklug
Posts: 8
Joined: 2014-05-09 11:21:13

Re: transforming paragraph style to pagebreak

Post by janklug » 2014-05-12 11:06:23

Thanks a lot!

The find-and-replace works well; the macrioze-version unfortunately not.

This is what I get from the 'copy to clipboard' macroization:
Find and Replace '(End of Paragraph)', '(Page Break)', 'eauU'

The 'Horizontal Line' attribute is somehow not included, so all 'end of paragraph's are replaced...

Jan

User avatar
phspaelti
Posts: 956
Joined: 2007-02-07 00:58:12
Location: Japan

Re: transforming paragraph style to pagebreak

Post by phspaelti » 2014-05-12 14:20:58

Yeah, that's the usual problem.
Apparently Nisus' "Macroize" feature doesn't transfer the necessary styles automatically. You'll have to copy the "Horizontal Line" style into the macro file and make sure it is applied to the relevant "Find and Replace" line of the macro. Even then the macro version may give you problems, depending on the attribute settings of the styles in either the macro file or the file where you are trying to run the macro. This is one area where the WYSIWYG nature of Nisus' interface is really not ideal.
philip

janklug
Posts: 8
Joined: 2014-05-09 11:21:13

Re: transforming paragraph style to pagebreak

Post by janklug » 2014-05-12 14:43:30

thank for the quick reply!
indeed I run into problems (although it's great to be able do do this; didn't expect that Nisus can do so many tricks!).

Problem seems to be that if I apply the 'Horizontal Style" to the search string, it is also applied to the replace string, which means that it places horizontal lines in the text after deleting them... But the page breaks are inserted!

best,

Jan

User avatar
phspaelti
Posts: 956
Joined: 2007-02-07 00:58:12
Location: Japan

Re: transforming paragraph style to pagebreak

Post by phspaelti » 2014-05-12 15:53:21

Speaking of tricks that Nisus can do, here's a different approach:

Code: Select all

$doc = Document.active
$hlStyle = $doc.styleWithName 'Horizontal Line'
Select Document Start
While Find Next $hlStyle, '-W'
    Insert:Page Break
end
philip

janklug
Posts: 8
Joined: 2014-05-09 11:21:13

Re: transforming paragraph style to pagebreak

Post by janklug » 2014-05-13 10:43:24

fantastic, that works!
a bit strange is that still Horizontal Lines are there after the Macro did its thing, but that was easily solved by changing the 'Horizontal Line' style to a style without a horizontal line ;)

Thanks a lot,

Jan

Post Reply