Skip to main content
Inspiring
May 1, 2024
Question

Code Scanning in RoboHelp 2020?

  • May 1, 2024
  • 3 replies
  • 263 views

Is there a code scan in RoboHelp (i.e., looking for empty tags, multiple span tags on content, etc.)?    

 

I've been noticing when our team has edited, we are getting these types of code issues and looking for a quick way to find them and fix them without having to review the code line by line.   

 

 

    This topic has been closed for replies.

    3 replies

    Inspiring
    May 2, 2024

    Afraid not, it's best to design structural rules to catch these things.

    In this case, the rule seems rather simple from a programming point of view.

     

    1. Find all <span> tags in the topic.
    2. For each <span> tag, check if they have actual content.
    3. If false, remove <span> tag.

     

    Or in actual code:

    import os
    from bs4 import BeautifulSoup

    project_folder = 'C:\\Users\\XXX\\XXX\\GitHub\\RH\\Projects\\XXX\\contents'

    def getLinks(project_folder):

        htm_files = []

        for root, dirs, files in os.walk(project_folder, topdown=False):
            for name in files:
                if name.endswith('.htm') or name.endswith('.hts'):
                htm_files.append(os.path.join(root, name))
        return htm_files

    htm_files = getLinks(project_folder)

    for htm_file in htm_files:
        with open(htm_file, 'r', encoding='utf-8') as file:
            data = file.read()
        soup = BeautifulSoup(data, 'html.parser')

        spans = soup.find_all('span')
        changes_were_made = False # to prevent saving every single file in project

        for span in spans:
            if len(span.contents) < 1:
                changes_were_made = True
                span.extract()

        if changes_were_made:
            with open(htm_topic, 'w', encoding='utf-8') as file:
                file.write(str(soup))

     

    As you encounter more and more issues, the number of rules will expand. On our end, we have about a dozen or so rules at the moment.

    Vicki5E13Author
    Inspiring
    May 2, 2024

    Thanks!   Didn't think of that.    

    Jeff_Coatsworth
    Community Expert
    Community Expert
    May 1, 2024

    Not that I've ever heard of - that mess looks like residual Word cruft. As Peter asks, "how are they editing"?

    Peter Grainge
    Community Expert
    Community Expert
    May 1, 2024

    How are they editing? Not something I have seen that bad. 

    ________________________________________________________
    My site www.grainge.org includes many free Authoring and RoboHelp resources that may be of help.

     

    Use menu (bottom right) to mark as Best Answer or to Highlight particularly useful replies. Found the answer elsewhere? Share it here.