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

Script to style paragraph following after headline

Return to Member Forum

  • Author
    Posts
    • #70117
      jpannier
      Member

      I’m new to scripting, I read a book, tried to follow but … I failed.
      The script I wanted to write is soo simple but I don’t get it. Maybe someone can help me.

      I want to format the paragraph following of certain headline-formats. So I need the script to check every paragraph of the active story. And if a paragraph has one of the headline formats, the next paragraph should become the format “no-indent”.

      I need a “for” and an inserted “if”, but to name the right variables and to find the right objects is my problem.

      I tried to adjust this script
      #target InDesign
      var _dok = app.activeDocument;
      var _allPages = _dok.pages;
      for (var i = 0; i < _allPages.length; i++) {
      var _page = _allPages[i];
      if (_page.textFrames.length > 0) {
      var _tf = _page.textFrames[0];
      var _firstPara = _tf.paragraphs[0];
      if (_firstPara .appliedParagraphStyle.name == “h1”) {
      _tf.paragraphs.nextItem(_firstPara ).appliedParagraphStyle = “no-indent”;
      }
      }
      }

      Because I need only the selected story and I wanted to integrate a general variable like this:
      var _pSName = .appliedParagraphStyle.name;
      to start:
      if ( _pSName == “h1” || _pSName == “h2”) {

      And I read that “nextParagraph” is better for long text than “nextItem”.

      Can anybody rearrange the code pieces to a running script?
      Thanks
      Jeldrik

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