7 Replies Latest reply on Mar 29, 2017 6:46 PM by Rob Bloom

    Avoid underline at the end of a line

    marcianovais

      How can I avoid underlined spaces at the end of a line?

       

       

      Screen Shot 2016-12-02 at 11.12.02.png

        • 1. Re: Avoid underline at the end of a line
          winterm Level 4

          You should be wayyy more specific... I bet that's the reason you didn't get any reply yet.

          Right now the short answer could be "just don't apply your underline to unwanted characters".

          If this occurs at the end of the story, you may try to trim unwanted trailing spaces with this GREP: \s+$

          • 2. Re: Avoid underline at the end of a line
            marcianovais Level 1

            Thank you for your reply.

             

            It's not on the end of the story, it's a paragraph that has multiple lines. I want when the line breaks, the space that is at the end of the line is not underlined. It would be easier to do it through a grep code, than doing it manually.Screen-Shot-2016-12-02-at-12.03.54.png

            • 3. Re: Avoid underline at the end of a line
              winterm Level 4

              Ah, I see your point now. It's multiline paragraph, right?

              Unfortunately, there's no such code to find these specific spaces.

              However, I'd be happy to stand corrected

              • 4. Re: Avoid underline at the end of a line
                [Jongware] Most Valuable Participant

                It is built-in behavior of InDesign. I wrote a script to apply a temporary fix to this years ago: http://indesignsecrets.com/topic/removing-end-of-line-underlines-83 (which I didn't remember but actually found by typing in your question into a well-known internet search engine).

                 

                The script contains a few characters that did not survive the translation to forum-formatted HTML, so I'll repeat it below for convenience:

                 

                //DESCRIPTION: Begone, Ugly End Of Line Underlining!
                // (c) Jongware 16-Dec-2009
                var blankStyle = app.activeDocument.characterStyles.item("NoUnderline");
                try { blankStyle.index; } catch(_)
                {
                 blankStyle = undefined;
                }
                if (blankStyle == undefined)
                {
                 blankStyle = app.activeDocument.characterStyles.add();
                 blankStyle.name = "NoUnderline";
                 blankStyle.underline = false;
                } else
                {
                 blankStyle.underline = false;
                }
                for (a=0; a<app.selection[0].lines.length; a++)
                {
                 if (app.selection[0].lines[a].characters.item(-1).contents == " ")
                 app.selection[0].lines[a].characters.item(-1).appliedCharacterStyle = blankStyle;
                }
                
                • 5. Re: Avoid underline at the end of a line
                  winterm Level 4

                  Ah, marvelous! Especially I like the Description

                  Maybe it might be mentioned the changes are permanent (not live), so you should run this nice piece of code only once, right before Final Output...

                  Edit: ups, there's ChStyle created, so it's possible to "revert back" after reflow and repeat the whole procedure... Even nicier

                  • 6. Re: Avoid underline at the end of a line
                    marcianovais Level 1

                    Thank you. I tried looking at InDesign Secrets forum, but I didn't see your reply.

                     

                    Great, it works! Thank you.

                    • 7. Re: Avoid underline at the end of a line
                      Rob Bloom

                      This script works. However, if you edit the text or adjust the width of the text box and wind up with different line breaks, where script fixed the underlined space now results in unintended gaps (without underlines) between words, which would require additional editing.

                       

                      Essentially an example of text would look like this:

                       

                      Original:

                       

                      The quick brown fox

                      jumped over the lazy

                      dog.

                       

                      After script and then line length adjustment:

                       

                      The quick brown fox jumped over the lazy dog.

                       

                      Notice the space between "fox" and "jumped" and "lazy" and "dog"?

                       

                      Try it and you will see.

                       

                      This issue is not present in Quark XPress.