Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Preserving *local* formatting not in paragraph style

New Here ,
Feb 14, 2008 Feb 14, 2008
I've been using Dave Saunders' PreserveLocalFormatting script, (http://indesignsecrets.com/plug-ins-and-scripts/) which creates and applies character styles.
This works great except that it applies character styles even when the paragraph style includes that same formatting. It applies the formatting twice: the paragraph style says the font is bold AND a bold character style is applied.
Is there a(n easy) way to get this script to only look at formatting that deviates from the defined paragraph style? Has someone (perhaps Dave himself?) already done this?
Thanks!
TOPICS
Scripting
829
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 14, 2008 Feb 14, 2008
That's one of the things that annoys me about that script. But it hasn't annoyed me enough to trigger me into doing anything about it.

Dave
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 14, 2008 Feb 14, 2008
Here's a function I use to get locally overridden formatting. To adapt
this to the script, you would have to change it to first buold an array
of finds by searching, and then step through the results to apply the
formatting if the function returns the formatting as part of the
overrides. I don't have the time now to do the adaptation myself, but
half the work is done...

(bye the way, the charStyle is optional. If it's defined it will only
find overrides of the character style.)

function GetCharOverrides(text,doc,charStyle){
var x;
var text = text.properties;
var paraStyle = text.appliedParagraphStyle.properties;
var inProps = {};var outProps = {};
if(doc.characterStyles.length<2){var tempStyle =
doc.characterStyles.add();}
else{var tempStyle = false;}
var a = doc.characterStyles[1].properties;
for(x in a){inProps = paraStyle;}
if(charStyle&&charStyle!=doc.characterStyles[0]){
charStyle = charStyle.properties;
for(x in charStyle){
if(charStyle&&charStyle!=NothingEnum.NOTHING){
inProps = charStyle;
}
}
}
delete inProps.basedOn;
delete inProps.name;
delete inProps.id;
delete inProps.parent;
delete inProps.index;
delete inProps.imported;
delete inProps.label;
delete inProps.properties;
delete inProps.gradientStrokeStart;
delete inProps.gradientFillStart;
for(x in inProps){
if(text!=inProps){
if(x=='appliedFont'){
try{
var textFont = text.appliedFont;
var inFont = inProps.appliedFont;
var textFontStyle = textFont instanceof Font ?
textFont.fontStyleName : text.fontStyle;
var inFontStyle = inFont instanceof Font ?
inFont.fontStyleName : inProps.fontStyle;
if(textFontStyle != inFontStyle){outProps.fontStyle
= textFontStyle}
var textFontFamily = textFont instanceof Font ?
textFont.fontFamily : textFont;
var inFontFamily = inFont instanceof Font ?
inFont.fontFamily : inFont;
if(textFontFamily !=
inFontFamily){outProps.appliedFont = textFontFamily}
}catch(e){}
}
else{outProps = text;}
}
}
if(tempStyle){tempStyle.remove();}
return outProps;
}

Harbs
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 14, 2008 Feb 14, 2008
I realized the other day why gradientStrokeStart and gradientFileStart always evaluate to different when comparing the style to the formatting -- it's because they're arrays so you can't compare them in the normal way. You have to compare the values of each member.

Dave
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 14, 2008 Feb 14, 2008
Dave_Saunders@adobeforums.com wrote:
> it's because they're arrays so you can't compare them in the normal way. You have to compare the values of each member.
>
Good point. Thanks.
I'll just stick with ignoring those properties, though. I have yet to
come across the need to preserve them... ;)

Harbs
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 18, 2008 Feb 18, 2008
Why does it matter?

Plus, oft-times when utilising this script, there won't be a paragraph style with eg italics in it, because using this script means you don't need to! (it does feel weird at first to have a whole paragraph styled italic via character style, but you soon get used to it...)

I wonder also whether it's better to keep the character style bold even where the paragraph style is bold in case something globally needs to be done to that character style. They you know you'll get all of them.

Also, just wondering why there is no underline option? I know it's generally frowned on to use underlining, but references still use them.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 19, 2008 Feb 19, 2008
Hi Kath,

You're the second person to raise the issue of underlines. Underlines are neither a format nor a position, so it's not trivial to add as an option, but it's not hard either--until you start trying to auto deal with text that has a mix of formatting, such as an italicized, superscipted, underlined character.

I originally wrote the script to deal with common problems that I encountered in my work. So, that's why it deals with what it does -- the version I use also handles a bunch of Greek symbols because one of my clients is in the biochemical field and they use them a lot.

Dave
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 19, 2008 Feb 19, 2008
LATEST
Hi Dave,

Hmm, I didn't realise underlines were different. I guess the easiest way for
me to deal with them is to save a search/replace and use it where needed
with imported Word documents, and keep an eye out for any other formatting
in that particular text.

I would assume that with this scripting you would have to do every
permutation and combination as you can't have more than one character style
at once, eg
italic and bold
italic and not bold
bold and not italic
etc.
Plus any other variable!

Katharine
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines