Reply to topic  [ 8 posts ] 
Setting The Style For Unstyled Paragraphs 
Author Message

Joined: 2007-08-17 14:21:25
Posts: 12
Location: Somerset, England
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?

_________________
Simon Wolf


2007-08-17 14:46:56
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
I'm going to guess what you want is possible, but I'm not sure exactly what you're after. What criteria do you want to use for selecting paragraphs that need to have styles applied? You just want to select all paragraphs without any paragraph style and then apply your Body style?


2007-08-17 18:27:32
Profile WWW

Joined: 2007-08-17 14:21:25
Posts: 12
Location: Somerset, England
Post 
Yes, exactly right, I was to select all paragraphs without a paragraph style and apply my Body style.

_________________
Simon Wolf


2007-08-17 23:40:53
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
Hi Simon, I'm sorry to say I spoke too soon. There's no way to select all the text in your document that has no paragraph style applied. Does the text you want to apply your style to really have no style applied, or just some generic style like Normal that you don't care for?


2007-08-19 19:48:30
Profile WWW

Joined: 2007-08-17 14:21:25
Posts: 12
Location: Somerset, England
Post 
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 ... :wink:

_________________
Simon Wolf


2007-08-19 23:51:06
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
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:
$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


2009-12-20 05:29:53
Profile

Joined: 2006-12-08 00:46:44
Posts: 417
Location: London or Exeter, UK
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


2009-12-20 07:18:50
Profile

Joined: 2007-03-03 09:55:06
Posts: 494
Location: Europe
Quote:
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...

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.

Cheers, Henry.


2009-12-21 06:25:54
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software