Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Change hyphenation options in script?

Return to Member Forum

  • Author
    Posts
    • #56913

      When I import text from Word, it usually comes in with some random style override or other on all the paragraphs. Character direction is the usual one, but sometimes I get kinsoku as well. These I can change quite easily by calling Find/Replace through a script.

      But I also get hyphenation overrides (hyphenation is turned off, and/or the hyphenation zone is changed). I'd like to set these back to the defined parameters for the paragraph style, but I can't seem to find any way to set the search either manually or scriptily.

      I'd rather not just remove all overrides until I'm sure that there aren't any overrides I want to keep, but it's hard to hunt through for ones that might be of interest when every single paragraph in the document has overrides.

      Does anyone know how I can reach the hyphenation options with a search, or otherwise remove these overrides without disturbing the rest of the document? (Bear in mind that (a) I have about 30 paragraph styles, and (b) not every paragraph style is intended to have the same hyphenation settings.)

    • #56916

      Well, I used to be able to remove kinsoku settings with a script. I've just run the script on a new document, and now the Applescript line:

      set kinsoku set of find text preferences to soft kinsoku

      results in the find text preferences being set as:

      + Kinsoku: No kinsoku

      Is this something they've done in the latest update to stop us from using scripts to get at things unobtainable through the user interface?

      This is, of course, a slightly different issue from my original question.

    • #56918

      (Would you mind asking script-specific questions in the Scripts section of the forum? I think David wants to keep his forum tidy ;) )

      This quick hack of a Javascript will reset all 10 (!) hyphenation options of each paragraph to the values defined in the applied style. I tested only on a small document; I suppose it might take some time on a longer document (whereas the number of paragraph styles has no influence at all).

      allPars = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();
      for (p=0; p<allPars.length; p++)
      {
      style = allPars[p].appliedParagraphStyle;
      if (!style.isValid) continue;
      allPars[p].hyphenWeight = style.hyphenWeight;
      allPars[p].hyphenateAcrossColumns = style.hyphenateAcrossColumns;
      allPars[p].hyphenateAfterFirst = style.hyphenateAfterFirst;
      allPars[p].hyphenateBeforeLast = style.hyphenateBeforeLast;
      allPars[p].hyphenateCapitalizedWords = style.hyphenateCapitalizedWords;
      allPars[p].hyphenateLadderLimit = style.hyphenateLadderLimit;
      allPars[p].hyphenateLastWord = style.hyphenateLastWord;
      allPars[p].hyphenateWordsLongerThan = style.hyphenateWordsLongerThan;
      allPars[p].hyphenation = style.hyphenation;
      allPars[p].hyphenationZone = style.hyphenationZone;
      }

    • #56929

      Oops! For some reason I was thinking there wasn't a scripts forum. But I think I must have been misremembering my thought of a few days earlier in which I was wondering if it might be an idea to have a separate GREP forum.

      Your script works perfectly, thanks ever so much!

    • #57439
      Anonymous
      Inactive

      Would it be possible to add resetting character direction overrides to the paragraph style defaults to this script? I attempted it myself, but haven't been able to get it to work properly (being a novice and such).

    • #57440

      It would, except I don't know how to express that in a script. I haven't encountered any 'bad' character directions myself — so far, and hoping to continue that.

      If you don't mind logging on to Adobe, you could ask this in the InDesign Scripting Forum. There are a couple of regulars over there that work with ID ME or are otherwise familiar with other language directions.

    • #57450
      Anonymous
      Inactive

      I found the following line of code on the Adobe forum from Harbs:

      app.selection[0].characterDirection = CharacterDirectionOptions.DEFAULT_DIRECTION;

      It works. I was trying to integrate it into the allPars[p]. format you have above, but I couldn't get it to run. But it still does the job sitting on its own line at the end of your script, so I'll leave it there.

      I'm getting the character direction override on every Word 2003 document I am importing into ID5. Doesn't happen with ID4 for the exact same docs. I am mapping styles. With hyphenation, if I reset the Word 2003 doc so the settings actually match the ID5 paragraph style hyphenation settings, the override goes away. But there is no way to set character direction in Word that I've found, so I have no options to get this to work. I import many small docs a day, the same docs where editors refresh the text, so even running this script each time I import is driving me batty. I may have to start working on moving my editors to InCopy.

      Thanks! Nancy

    • #104126
      Gopa Campbell
      Participant

      Can someone tell me how to get the script shown above into my list of scripts in Indesign?

Viewing 7 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads