I have an rtf document created by a 1989 PC application. It strucutres a report from the application which in my example has 300 entries. When I open the doc in NWP it does not recognise any styles, but say "Heading 2" is 12pt Arial Narrow, Bold Italic Underlined.
The next line is 10pt, same font but not underlined. Etc
I want to process all 300 entries and set a style and modify the source settings.
I have looked at the macro language and I presume the answer is in there.
I use Applescript a lot so can apply that but its not enough. I'm not good at regex which also might do it?
Here is an example of the text:
42 Facility
General attributes
Object kind: Entity
Notes: A complex of assets above and below ground comprising Buildings, Site Infrastructure(Siteworks and Site Services) which represents a single management unit for financial, operational, maintenance or other purposes.
Source: based on NPWC
Name space:
Value/Range:
Can anyone suggest an approach or give me an example I can customise?
TIA
selecting a specific style and changing it
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: selecting a specific style and changing it
It's likely some kind of find & replace operations and/or macro commands can do the job for you. But without knowing exactly what you want, it's hard to advise.
You can do a Find All, and then just apply the desired paragraph style to all selected paragraphs. Probably you can see how to adapt this method to cover your other prefixed paragraphs.
Your other paragraphs might be more difficult, eg:
So you want to apply paragraph styles to all paragraphs that show similar information? For example, you gave:I want to process all 300 entries and set a style and modify the source settings.
Formatting the paragraphs that always begin with the same prefix (eg: "Object kind:") is quite easy. Just set the Find mode to PowerFind Pro and use this search pattern:Object kind: Entity
Code: Select all
Object kind:.+
Your other paragraphs might be more difficult, eg:
Are these paragraphs always numbered? Are there any other numbered paragraphs?42 Facility
-
- Posts: 10
- Joined: 2010-10-25 02:41:35
Re: selecting a specific style and changing it
Michael tks for feedback; I tried the expression "Object kind:.+" in Powerfind (quotes are for here) and it said Found no occurrences!
However a plain Find with the specific text "Object kind:"did find all and I can style them.
So that leaves the Headings eg "42 Facility". They are all unique and number 1 to 311...
I assume a regex 'start at beginning of line, if there is a number, select the line and find all'?
I experimented with the Find tool Constructor button and created this "\<^[[:digit:]]" which allowed me to select all 311 "headings" & set a style
How would you make this more rigorous? And can I save that as a macro. (The manual is daunting - and no examples!)
However a plain Find with the specific text "Object kind:"did find all and I can style them.
So that leaves the Headings eg "42 Facility". They are all unique and number 1 to 311...
I assume a regex 'start at beginning of line, if there is a number, select the line and find all'?
I experimented with the Find tool Constructor button and created this "\<^[[:digit:]]" which allowed me to select all 311 "headings" & set a style
How would you make this more rigorous? And can I save that as a macro. (The manual is daunting - and no examples!)
Re: selecting a specific style and changing it
Hi, jrmitchell.jrmitchell said:
… I tried the expression "Object kind:.+" in Powerfind …
Actually you should select PowerFind Pro, not PowerFind, from the pop-up menu. PFP uses a special language called grep to formulate expressions that match specific text. A period (.), for example, finds any character except newline (return). + sign stands for one or more of the previous. So .+, in Martin’s suggestion, means one or more characters (except newlines) until the end of the paragraph (since a newline character is not found by period).
If you want to know more about grep, you can google for it. I don’t have any address offhand, sorry.
Cheers, Henry.
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: selecting a specific style and changing it
As Henry mentioned, you'll need PowerFind Pro to use regular expressions directly. The normal PowerFind just allows for the use of our special PowerFind "bubbles" which help those unfamiliar with regular expressions build up searches, which it sounds like you discovered.jrmitchell wrote:Michael tks for feedback; I tried the expression "Object kind:.+" in Powerfind (quotes are for here) and it said Found no occurrences!
Ah yes, I forgot about that. Paragraph Styles always apply to the entire paragraph, so it doesn't really matter if you select the whole paragraph or not before you apply the paragraph style.However a plain Find with the specific text "Object kind:"did find all and I can style them.
Great, I'm glad your experiments paid off!So that leaves the Headings eg "42 Facility". They are all unique and number 1 to 311...
I assume a regex 'start at beginning of line, if there is a number, select the line and find all'?
I experimented with the Find tool Constructor button and created this "\<^[[:digit:]]" which allowed me to select all 311 "headings" & set a style
In what way did you want to make this more rigorous? It all comes down to the document you have, and any false matches you need to avoid. For this particular type of paragraph, it appears that your digits are always followed by a tab? If so, you might consider either of these:How would you make this more rigorous?
Code: Select all
\<^[[:digit:]]+\t
^\d+\t
Yes indeed. Once you have a Find expression entered and working, just use the "Macroize" command from the little gear icon menu. That will let you save (or copy) the Find expression in its macro form. Since you want to also apply styles as part of your macro, you'll want to use the name of your style after the find expression in your macro, eg:And can I save that as a macro. (The manual is daunting - and no examples!)
Code: Select all
Find All 'Object Kind', 'a'
Heading 2
-
- Posts: 10
- Joined: 2010-10-25 02:41:35
Re: selecting a specific style and changing it
The solution gets better & more understood. Tks for the support