1 Reply Latest reply on Aug 29, 2016 7:56 AM by Willam van Weelden

    Replacing a Style or Paragraph Tag with Another




      I am trying to find the API to set the style in RoboHelp Script. In the Clean Project Example (as in the following code snippet), it shows how to find a undefined style and remove that style. In this case, instead of token.removeAttribute("style"), is it possible to set a style, for example, a paragraph tag, say "body". Also, is it possible to find a paragraph tag, say "Normal", and replace it with "body" paragraph tag.


      if(token.tokenType == RoboHelp.TokenType.TOKENTAG)
      //Does this token have style attribute?
      if(token.getAttribute("style") != "")
      //This token has a style attribute. Now remove the style attribute.


        • 1. Re: Replacing a Style or Paragraph Tag with Another
          Willam van Weelden Adobe Community Professional & MVP

          You want to set a style name? In that case: (note: I didn't run/test this, but it should at least point in the right direction)


          if(token.tokenType == RoboHelp.TokenType.TOKENTAG && token.hasAttribute("style") == true) {





          The above will assign the class 'myStyleName'. You'll, of course, want to check the type of tag and whether you need to assign the style.


          Something that I have been having fun with: you'll have to save before closing the TokenManager. Otherwise you'll be wondering why the script won't work. Embaressed to say I've forgotten this more than once...

          tokens.save();//Save changes

          tokens.close();//Close the TokenManager or you'll run out of memory