7 Replies Latest reply on Feb 19, 2008 2:19 PM by (kath_shade)

    Preserving *local* formatting not in paragraph style

      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?
        • 1. Re: Preserving *local* formatting not in paragraph style
          Level 1
          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.

          • 2. Re: Preserving *local* formatting not in paragraph style
            Harbs. Level 6
            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 =
            else{var tempStyle = false;}
            var a = doc.characterStyles[1].properties;
            for(x in a){inProps[x] = paraStyle[x];}
            charStyle = charStyle.properties;
            for(x in charStyle){
            inProps[x] = charStyle[x];
            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){
            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}
            else{outProps[x] = text[x];}
            return outProps;

            • 3. Re: Preserving *local* formatting not in paragraph style
              Level 1
              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.

              • 4. Re: Preserving *local* formatting not in paragraph style
                Harbs. Level 6
                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... ;)

                • 5. Re: Preserving *local* formatting not in paragraph style
                  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.
                  • 6. Re: Preserving *local* formatting not in paragraph style
                    Level 1
                    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.

                    • 7. Re: Preserving *local* formatting not in paragraph style
                      Level 1
                      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
                      Plus any other variable!