4 Replies Latest reply on Nov 23, 2011 1:08 AM by Tom Tomasko

    Question on use of discretionary hyphens

    Tom Tomasko Level 1

      Hello,

       

      I hope someone can solve the following conundrum!

       

      I want to make sure that compound words (ex: official-looking) do not break at any syllable at the end of the line. It then looks unsightly when the word has two hyphens.

       

      If I put a discretionary hyphen at the beginning of the second word, then neither word will break and it will break at the hard hyphen. This works but I do not understand why. Further, if I put the d. hyphen in front of the first word, then neither word breaks nor will it break at the hard hyphen, which is not a good result.

       

      But then the problem deepens.

       

      I also do not want the words prior and after an em dash to break. Breaking the words in this instance also looks bad. Again, if I put the d. hyphen before the second word, the phrase will break at the em dash but neither word will break except under the following condition:

       

      If the second word has only one syllable the first word will break.

       

      I could fix that by puttinga d. hyphen before the first word, but then it will never break at the em dash.

       

      Any ideas?

       

      Thanks,

      Tom

        • 1. Re: Question on use of discretionary hyphens
          Joel Cherney Adobe Community Professional & MVP

          Sorry, I probably can't actually answer your question, I'm just trying to save you from the dustbin of page two.  I tried to write up a GREP style suggestion for you, but maybe you've already considered this? I decided it'd probably take two GREP searches to apply No Break to either side of a compound word separated by a hyphen, and it felt like an awkward suggestion. Then, I tossed the question at Google, and found that Kenneth had posted about this issue in 2007. Interestingly, that thread covers this question (and a partial answer, why a GREP style won't work), and the odd behavior of the discretionary hyphen when used in a compound word with No Break applied.

           

          Maybe there's some sort of obvious non-GREP answer. I often manage to gin up hacky solutions in these kinds of cases with a zero-width space, e.g. [word][nonbreaking hyphen][ZWS][word], in a paragraph style with hyphenation turned off. However, I doubt that's the answer, and if there is a good non-GREP answer, I simply can't consume enough coffee to make my brian generate the answer. Best of luck.

          • 2. Re: Question on use of discretionary hyphens
            Peter Spier Most Valuable Participant (Moderator)

            Joel, for some reason that link you posted is blank (or should I say only has http:/// in it). Would you mind trying again?

            • 3. Re: Question on use of discretionary hyphens
              Joel Cherney Adobe Community Professional & MVP

              Whoops! Here's a valid link - I think that new Jive code must be fighting with some other JS stuff I run in Firefox - if I don't click Insert twice then the link gets lost.

               

              So, Tom, would running a multi-pass search-and-replace work for you?

              • 4. Re: Question on use of discretionary hyphens
                Tom Tomasko Level 1

                I don't think a multi-pass is necessary.

                 

                For compound words I search for: ([\w.]+-)([\w.]) This also finds any compound words that are also initials (U.S.-U.S.S.R).

                 

                Then I do a replace: $1~-$2. This allows the compound word to break at the hard hyphen but does not allow either word to break. What I don't understand is why the first word does not break. A discretionary hyphen before a word tells ID not to break that word. But the first word in the compound has no such d. hyphen.

                 

                For the words prior to and after an em dash I search for: (\w+)(~_)(\w+)

                 

                For replace I use: $1~-$2~-$3 This puts a d. hyphen before and after the em dash. It appears to me--I still don't get it--that this will stop either word from breaking but will allow a break either before or after an em dash.

                 

                Tom