To help me evaluate Nisus Writer Pro I imported a pretty hefty document that I have been working on. It came across pretty well but since it was a Pages document that I exported to RTF and then opened it lost all of the styles that I had defined. This is not a major problem but it would save me a lot of time if I only had to create new styles for headings and a few other items and was then able to designate every other paragraph without a style as being my 'Body' style.
Is this sort of thing possible?
Setting The Style For Unstyled Paragraphs
Setting The Style For Unstyled Paragraphs
Simon Wolf
Hi Martin,
There was no style selected at all (as far as I can tell ... maybe because I didn't have a style called Normal nothing was displayed). Anyway, don't worry too much because as I worked through the document checking that everything had come in properly and that it was all laid out properly I added the paragraph styles.
Now, if there was better AppleScript support ...
There was no style selected at all (as far as I can tell ... maybe because I didn't have a style called Normal nothing was displayed). Anyway, don't worry too much because as I worked through the document checking that everything had come in properly and that it was all laid out properly I added the paragraph styles.
Now, if there was better AppleScript support ...

Simon Wolf
Re: Setting The Style For Unstyled Paragraphs
Thanks to the great improvement of the Nisus Macro language, now we can write such a macro. I'm not using Pages but sometimes I need to do the same thing, for example, when formatting an etext.
Code: Select all
$defaultParagraphStyleName = 'Normal' # Put an appropriate paragraph style name between the single quotes
Require Pro Version 1.3
$doc = Document.active
if $doc == undefined
exit # exit silently
end
$paras = $doc.paragraphStyles
$defaultParagraphStyle = undefined
foreach $para in $paras
if $para.name == $defaultParagraphStyleName
$defaultParagraphStyle = $para
Break
end
end
if $defaultParagraphStyle == undefined
exit "You have to create or import \"$defaultParagraphStyleName\" paraagraph style before running this macro, exiting..."
end
$sels = $doc.text.findAll '^\p{Any}', 'E', '-am' # in the main document body only
foreach $i, $sel in reversed $sels
if $sel.text.documentContentType != 'body' # then, $sel is in a table
$sels.removeValueAtIndex $i
else
$attr = $sel.text.attributesAtIndex $sel.location
if $attr.paragraphStyle != undefined # then, this paragraph has a style
$sels.removeValueAtIndex $i
end
end
end
if $sels.count
Push Target Selection $sels
$defaultParagraphStyle.apply
Pop Target Selection
else
exit 'There is no paragraph not having a paragraph style, exiting...'
end
Re: Setting The Style For Unstyled Paragraphs
Hi Simon, I don't know if this is what fits your case, but if I have an imported file in which I'm going to have to style everything, what I do is immediately select all and apply my body style. Only after that do I go down changing the headings and subheadings and anything else that needs it to what I want.
Too late for this time, I guess, and maybe Kino's macro would suit you better, but that has always been my approach.
Mark
Too late for this time, I guess, and maybe Kino's macro would suit you better, but that has always been my approach.
Mark
Re: Setting The Style For Unstyled Paragraphs
Hi, Simon. Have you tried exporting the file into .doc from Pages and opening it in NWPro? I seldom use Pages, yet it seems to me it is peculiar at dropping styles while preserving formatting.Simon said:
...It came across pretty well but since it was a Pages document that I exported to RTF and then opened it lost all of the styles that I had defined...
Cheers, Henry.