• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Replacing a Style or Paragraph Tag with Another

New Here ,
Aug 28, 2016 Aug 28, 2016

Copy link to clipboard

Copied

Hi,

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.
token.removeAttribute("style");
}
}

Thanks.

Views

178

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 29, 2016 Aug 29, 2016

Copy link to clipboard

Copied

LATEST

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) {

   token.removeAttribute("style");

   token.setAttribute("class","myStyleName");

}

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
RoboHelp Documentation
Download Adobe RoboHelp