6 Replies Latest reply on Jan 4, 2013 9:53 PM by Jump_Over

    Change Manual hyphen into Discretionary Hyphen

    BEGINNER_X Level 3

      Hi ALL,

       

      Requirement:

       

      I want to change all manual hyphen at the end of line into Discretionary Hyphen especially in emails etc.....

       

       

      Using the below script i change all the manual hyphen into Discretionary Hyphen, but throughout the document. [Note: Not in the end of line alone]

       

       

      //Change throughout the document script

       

      var myDocument = app.activeDocument

       

      app.findTextPreferences.findWhat = NothingEnum.nothing

      app.changeTextPreferences.changeTo = NothingEnum.nothing

       

      app.findTextPreferences.appliedCharacterStyle = "AAA"

      app.findTextPreferences.findWhat = "-"

      app.changeTextPreferences.changeTo = ""   //within double quotes discretionary hyphen is there

      app.activeDocument.changeText()

      app.findTextPreferences.findWhat = NothingEnum.nothing

      app.changeTextPreferences.changeTo = NothingEnum.nothing

       

      Above script works properly

       

       

      Finally i got relavant script from forum regards checking all the lines after that i try to tuned for my script. But i dont know exactly what i want to do.

       

      var myDocument = app.activeDocument;

      var myLine = myDocument.stories.everyItem().lines.everyItem().getElements();

      for(i=0; i<myLine.length; i++)

      {

      var myHyphen = myLine[i].texts[-1].hyphenateLastWord(true)

      // i dont know

      //  

              }

          }

         

       

      Screen Shot 2013-01-03 at 6.12.57 PM.png

       

      Please can anyone give solution. I dont know how to do this script using discretionary hyphen.

       

      Thanks in advance

      BEGINNER

        • 1. Re: Change Manual hyphen into Discretionary Hyphen
          Jump_Over Level 5

          Hi,

           

          modify this alike:

           

          for (i = 0; i < myLine.length; i ++)

          if (myLine[i].characters[-1].contents == "-")

              myLine[i].characters[-1].contents = SpecialCharacters.DISCRETIONARY_HYPHEN;

           

           

          The problem is that if your story uses paragraph text composer, some of manual "-" could be pushed from the end of line and they would stay untouched

           

          rgds

          1 person found this helpful
          • 2. Re: Change Manual hyphen into Discretionary Hyphen
            BEGINNER_X Level 3

            Hi Jump_Over,

             

            Thanks for your reply....

             

            Its very helpful answers for me. Later i try and create the code and it works fine for me.

             

             

            var myDocument = app.activeDocument

             

            app.findTextPreferences=app.changeTextPreferences =null

             

             

            app.findTextPreferences.appliedCharacterStyle = "Email"

            app.findTextPreferences.findWhat = "-"

             

            var myFoundItems = myDocument.findText(true)

             

            for(i=0; i<myFoundItems.length; i++)

            {

                if(myFoundItems[i].lines[0].characters[-1].contents == "-")

                {

                    myFoundItems[i].lines[0].characters[-1].contents = SpecialCharacters.DISCRETIONARY_HYPHEN

                    }

                }

             

             

            Again thanks a lot....

             

            BEGINNER

            • 3. Re: Change Manual hyphen into Discretionary Hyphen
              BEGINNER_X Level 3

              Hi ALL,

               

              I changed all manual hyphen at the end of line into Discretionary Hyphen  using above script.

               

               

              MY QUESTION:

               

              Is it possible to avoid reflow after change manual hyphen into discretionary hyphen?

               

              [Note: Want line end as it is in the previous stage]

               

               

              What i am trying is, use shift return after discretionary hyphen. No reflow but the discretionary hyphen is missing. So no use of it.

               

              Before running script my file is:

               

              Screen Shot 2013-01-04 at 5.47.01 PM.png

               

               

              After running the script my file get reflow in that paragraph. See my file below

               

              Screen Shot 2013-01-04 at 5.50.21 PM.png

               

               

              Any solution to avoid reflow within the paragraph using indesign or indesing scripting.

               

               

              Thanks  to all forum members

              BEGINNER

              • 4. Re: Change Manual hyphen into Discretionary Hyphen
                Richard Groff Level 1

                That's just the way a discretionary hyphen works. If it occurs near the end of a line and it's within the hyphenation limit, it will hyphenate there. If not, it won't.

                • 5. Re: Change Manual hyphen into Discretionary Hyphen
                  BEGINNER_X Level 3

                  Hi Richard/ALL,

                   

                   

                  Thanks for your reply...

                   

                  Atleast is it possible in script, to want line end as it is in previous stage after change manual hyphen in discretionary hyphen.

                   

                   

                   

                  Thanks in advance

                  BEGINNER

                  • 6. Re: Change Manual hyphen into Discretionary Hyphen
                    Jump_Over Level 5

                    Hi,

                     

                    If you don't want text to reflow ==> leave manual hyphen (no matter if you replace them)

                    Otherwise you are runing in circles

                     

                    rgds