I download a series of court judgements each which contain some applied formatting.
I know it is possible to remove all of it, and also individual elements of the applied formatting.
What I would like to do is to create a macro which removes only some individual elements and one style.
For example in the following:
after selecting all, I would like to remove the Text Color, Underline, Paragraph Spacing Before formatting and the Style: Hyperlink
(Some of the applied formatting varies from judgement to judgement, for example the Text Color is red or blue)
Is this possible?
Macro to remove some applied formatting
Re: Macro to remove some applied formatting
Of course you can do this, but you may need to be a bit careful.
Generally Nisus has commands to change formatting like:
as it's described in the reference. So if you have everything selected and use
Then all bold is removed from your document. Interestingly enough this will even apply to the Bold that is applied through styles. It seems Nisus adds an "Unbold" attribute to those sections.
In the same way you should be able to use
Where the "0" stands for no underline. If the underline was applied directly this will remove it. If the underline was applied with a style it will 'cover it' with a 'no underline' attribute.
Then you say you want to "remove the text color".Of course there always has to be some text color. I guess most people consider "black" the default. The command Set Text Color requires a color argument. I can't see a way to say "none".
Again if the color is applied via a style this will 'hide' the color by applying black over it.
Finally removing character styles: First select all in the style and the use "Remove Character Styles". For example you can select all in the style using Find. In that case it's a good idea to use a test to make sure you only remove the style in case some was found.
[NB: I'm assuming you have set $doc to the the current document.]
Finally for the paragraph spacing you will have to know more specifically how you want to change it. There are command to set the spacing before and after, but the line height will have to be set using the menu formatting.
Finally remember that you can also reapply paragraph styles in order to enforce the default formatting as another way to clean up applied attributes.
Generally Nisus has commands to change formatting like:
Code: Select all
Set Bold isBold
Code: Select all
Set Bold @false
In the same way you should be able to use
Code: Select all
Set Underline 0
Then you say you want to "remove the text color".Of course there always has to be some text color. I guess most people consider "black" the default. The command Set Text Color requires a color argument. I can't see a way to say "none".
Code: Select all
$black = Color.black
Set Text Color $black
Finally removing character styles: First select all in the style and the use "Remove Character Styles". For example you can select all in the style using Find. In that case it's a good idea to use a test to make sure you only remove the style in case some was found.
Code: Select all
if Find All $doc.styleWithName 'Hyperlink'
Remove Character Styles
end
Finally for the paragraph spacing you will have to know more specifically how you want to change it. There are command to set the spacing before and after, but the line height will have to be set using the menu formatting.
Finally remember that you can also reapply paragraph styles in order to enforce the default formatting as another way to clean up applied attributes.
philip
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Macro to remove some applied formatting
Instead of using these "Set" commands, it's probably better to work via menu commands like:
Code: Select all
Remove Text Color Formatting
Remove Underline Formatting
However, the original goal doesn't require a macro. The Formatting Examiner palette will let you pick and choose which applied formatting to remove:
1. Select all the text in your document.
2. Click the Formatting Examiner palette's listing to select a single formatting attribute (eg: Underline).
3. Hold down the Command key and click other listed formatting attributes to add them to the selection.
4. Once you've selected all the desired formatting, click the gear icon button to show the popup menu.
5. Choose the command "Remove Selected Formatting" from the popup menu.