Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Not that I've ever heard of - that mess looks like residual Word cruft. As Peter asks, "how are they editing"?
Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
Thanks! Didn't think of that.