I wonder how Paragraph Shading can be applied via a macro to paragraphs with a selection.
I fear did not understand how to use the commands given in the Macro help file.
Paragraph shading
Re: Paragraph shading
I thought that I had written a macro to do such a thing, but I can't find it. So maybe I was just imagining things. I was probably thinking about Table cells.
The fact is that attributes are still very much a step-child in Nisus' macro language. They can't be created, and attribute objects retrieved from the text can't be changed, or applied to other selections. There is an ".addNewStyle" command (for document objects) which takes an attribute object as argument, but that's about it.
One would hope that a future update would add some commands like:
but at this point this is just a wish.
The fact is that attributes are still very much a step-child in Nisus' macro language. They can't be created, and attribute objects retrieved from the text can't be changed, or applied to other selections. There is an ".addNewStyle" command (for document objects) which takes an attribute object as argument, but that's about it.
One would hope that a future update would add some commands like:
Code: Select all
Attributes.new [attribute list]
Selection.apply [attributes object]
philip
Re: Paragraph shading
Ok, so maybe I wasn't imagining things.
If you look in the macro reference in the section "Formatting Text" you will find the following:
So there you have it.
Here's a code example:
If you look in the macro reference in the section "Formatting Text" you will find the following:
Code: Select all
Set Paragraph Shading Attributes shadingAttrs
Here's a code example:
Code: Select all
$lightGray = Color.newWithHexTriplet 'CCCCCC'
$shade = ShadingAttributes.newWithSolidColor $lightGray
Set Paragraph Shading Attributes $shade
philip
Re: Paragraph shading
Thank you.
I did not understand that "color" as argument of ShadingAttributes can't be a simple color name like "yellow"
I did not understand that "color" as argument of ShadingAttributes can't be a simple color name like "yellow"
Re: Paragraph shading
Indeed. The extra step needed to use color in any command is a bit of a bother. And the shading attributes object command ".newWithBlendColors" requires two colors.js wrote:Thank you.
I did not understand that "color" as argument of ShadingAttributes can't be a simple color name like "yellow"
For this reason I usually use ".newWithPatternType" with argument 'Blend', but then you still need to set the blend ratio separately.
Code: Select all
$shade = ShadingAttributes.newWithPatternType 'Blend'
$shade.blendRatio = 0.25
Set Paragraph Shading Attributes $shade

philip