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

Marginal line numbers extracted from text

Return to Member Forum

  • Author
    Posts
    • #33997
      redbook
      Member

      I have a document that has numbers embedded in the text that need to be pulled out and set as marginal line numbers. The pattern is always the same, word space [number(one or two times)] word space (for example [5] [10] [15] and so on)

      Is there a script that will grab the grep phrase: \[d+\] remove them, and place in anchored boxes in the margins?

      This seems a nearly identical question to the post by chrislo878 on June 18th, so hopefully we will both get an answer from it.

      seems like a tall order, but there are 2047 in the job, so automation is really the key!

    • #34044

      Try something like this. Please check if the new forum didn’t interfere with the code!

      app.findGrepPreferences = null;
      app.findGrepPreferences.findWhat = “[d+]”;
      numberList = app.activeDocument.findGrep(true);

      for (i=0; i<numberList.length; i++)
      {
      tf = numberList[i].textFrames.add({anchoredObjectSettings:{anchoredPosition:AnchorPosition.ANCHORED, anchorXoffset:”1mm”}});
      tf.geometricBounds = [“0mm”,”0mm”,”10mm”, “50mm” ];
      numberList[i].move(LocationOptions.AT_BEGINNING, tf.texts[0]);
      tf.fit (FitOptions.FRAME_TO_CONTENT);
      }

      • #34047
        redbook
        Member

        wow, that was really fast!

        I copied and pasted both versions (this one on the forum, and also the one you emailed) into a new java script. Both give syntax errors when I try to run them. The email version in line 9 (the semicolon after “length” possibly, and in the forum version, line 2.

        I appreciate any insight you can give.

      • #34048
        redbook
        Member

        Nevermind!!! I got it to work (the quotes had turned into open and closed instead of straight, that was the problem.

        thanks so much, I can adjust to my exact needs now.

        YOU ARE GENIUS!

    • #34049

      Cool! Glad you could get it to work, Debugging By Proxy is hard.

      Also thanks for the heads up on the quotes. I’ll try and remember that next time I post a script — I don’t think David can make this issue go away on the forum.

      • #34058
        David Goodrich
        Participant

        Thanks, Jongware, I’ve saved this in my collectioon of JSX snippets. Most of the poetry I set needs to be indented within the main text block, and when line numbers are called for I alter my usual hanging indent, adding right-aligning tabs to control where they fall. But I’ve done prose translations where line nos. and edition references were needed in the right margin, and of course anchored frames would allow them to re-locate automatically when the translation was edited. (Back in Pagemaker days I faked this with a dedicated “windowshade” filled mostly, I’m ashamed to admit, with carriage returns I’d adjust manually.)

        David

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
Forum Ads