Replace styles in Table

Please post all questions and comments regarding Help & Manual 7 here.

Moderators: Alexander Halser, Tim Green

Post Reply
IngvarRu
Posts: 26
Joined: Wed Sep 16, 2015 1:18 pm

Replace styles in Table

Unread post by IngvarRu »

My project has many tables without styles. How can I assign a certain style of all tables?
I see the possibility of replacing the text style, paragraph, but not tables
User avatar
Tim Green
Site Admin
Posts: 23184
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Replace styles in Table

Unread post by Tim Green »

Hi Ingvar,

There's no global way to do this for tables within Help & Manual. However, you can use a multi-file search and replace tool on the source code of your topics, provided your project is saved in the uncompressed HMXP format so that you can access the individual files. You can save to HMXP with Save As... in the File menu. Choose an empty folder to save in (you can add other files and folders to it later if necessary, for example for your images etc).

First you need to create "before" and "after" examples of what you need to do in the HM editor, then look in the XML Source view (tab below the main editor window) to see the XML code you need to find and replace. Then use a multi-file search and replace tool on the topic files in the /Topics sub-folder in your project folder to make the changes.

In the case of table styles it's quite simple. You're going to be either looking for tables with no style at all, which looks like this

Code: Select all

<table rowcount="2" colcount="2" ...
Or tables with the default style, which looks like this:

Code: Select all

<table styleclass="Default" rowcount="2" colcount="2" ...
So you want to replace <table rowcount with <table styleclass="YourStyle" rowcount for the tables without any style at all, and <table styleclass="Default" with <table styleclass="YourStyle" for the tables that have the default style.

IMPORTANT: Always make a backup before doing this! Automated global changes are always a little bit risky. ;-)

If you don't have a suitable editor for this here's a list of ones you could use:

PowerGREP:
http://www.powergrep.com/

If you feel comfortable with regular expressions PowerGREP is the best tool available, on any platform and at any price. It is a little pricey, but if you do a lot complex searching in multiple files (also for programming work) it will pay for itself subjectively in a single afternoon. The RegexBuddy tool from the same company (http://www.regexbuddy.com/) is also the best interactive tool available for defining and testing regular expressions, and its documentation is quite literally the best tutorial and introduction to regular expressions available anywhere.

Notepad++ (free):
http://notepad-plus-plus.org/

Notepad++ also supports multi-file regular expression searching, if you feel comfortable with that, but it is more limited than PowerGREP but its search and replace is fine for this kind of task. It is also one of the best code editors available, at any price. I use it for all my web programming.

FAR HTML (inexpensive, generous free trial period)
http://www.helpwaregroup.com/products/far

FAR HTML is actually a Swiss Army knife for help authors, with a wealth of useful tools, not just the find and replace. It includes a special interface for complex searches, making them easier for users not familiar with the rather arcane syntax of regular expressions.

Windows Grep (less expensive and also less powerful than PowerGREP)
http://www.wingrep.com/index.htm

IMPORTANT: Always make a backup before doing this! Automated global changes are always a little bit risky. ;-)
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
IngvarRu
Posts: 26
Joined: Wed Sep 16, 2015 1:18 pm

Re: Replace styles in Table

Unread post by IngvarRu »

About edits to XML I know - I use akelpad. I tried to change the style of table - style is was replacement (seen in the properties of the table), but settings the tables do not apply (width, color of header).
I made by hand. But in general, I would like a system solution.
Post Reply