menu   UA Europe - Training & Consulting
UA Europe - Training & Consulting
UA Europe - Training & Consulting

Specialists in
User Assistance
technology

Exploiting the power of Find Elements in MadCap Flare

Published in ISTC Communicator, Autumn 2020.

In my view, one of the most interesting and useful changes in the 2020 release of MadCap Flare was the enhanced Find Elements tab of the Find and Replace in Files window. This tab existed in the previous version of Flare, and you could use it to easily locate specific structural elements such as html tags and classes within your content. The significant change in Flare 2020 is that you can now automatically replace or take other specified actions on the items that you find. Also new is the ability to combine search criteria in order to narrow down the results — for example, you can find a certain tag that has a specific attribute.

The following sections describe a range of different use cases for this powerful new feature.

Removing inline formatting

You can use Find Elements to remove all spans that have been used to apply inline formatting. To do this, you would find all span tags that have an attribute of style, and specify a Replace/Action of Unbind Tag, as shown below.

Screenshot showing Remove Spans

Finding and replacing h3 with h2

This task is quite straightforward — you would find a tag of h3 and the Replace/Action would be Set Tag h2. You can be selective about the replacements by clicking Find Next for some occurrences of h3 and Replace on others. Flare will, of course, take care of the closing </h3> tags automatically as well.

Removing all inline font-family style attributes

It is not uncommon for these style attributes (specifying a font such as Arial) to be present in content that has been imported into Flare, and they can cause problems if you need to change your default fonts by updating your stylesheet.

Using Find Elements, you could find Inline Formatting of font-family: and specify a Replace/Action of Remove Inline Formatting font-family: (as shown below).

Screenshot showing Remove inline font-family
			attribute

The risk here is that you could be left with redundant span tags with no attributes, if font-family were the only inline format set by the span. Here is an example of what you could end up with:

<p><span>This text previously had inline formatting that set the font to Arial</span></p>

Although the span tag is not causing any harm, it is now completely redundant, and it would be nice if there were some easy and automated way of unbinding these redundant tags. I can't see a way to do this using Find and Replace Elements, and would probably have to resort to using Regular Expressions in the Find and Replace Text tab.

Finding and replacing b tags with character styles

This is achieved by replacing b tags with a span class such as "UI-Term". In other words, you are changing the tag from b to span, and adding an attribute. Since Find Elements does not allow you to specify more than one action, you have to do this in two steps:

  1. Add the class of UI-Term.

  2. Change the tag from b to span.

So, you would start by finding all b tags and using a Replace/Action of Set Attribute class UI-Term (as shown below).

Screenshot showing Set class of UI-Term

This results in all your b tags appearing like this in your source XHTML code:

<b class="UI-Term">text</b>

Then you would find all b tags with a class of UI-Term and use a Replace/ Action of Set Tag span as shown below.

Screenshot showing Set tag of span

The final result would be this:

<span class="UI-Term">text</b>

Removing inline list-style-type property from lists

Inline list-style-type attributes are undesirable as they override the liststyle- type attribute specified by your style sheet. This can lead to inconsistent use of bullets or numbering.

You can remove these inline liststyle- type properties by finding Inline formatting of list-style-type: and removing it (you need to type the same code into the Remove Inline Formatting field), as shown below.

Screenshot showing Remove inline list-style-type

If you wanted to remove all inline formatting (including any of the properties available in XHTML) from lists, then, somewhat surprisingly, it is not possible to do this by finding and removing inline formatting. This is because Flare requires you to specify the inline formatting properties that you are looking for. However, you can remove all inline formatting from lists by finding ul and ol tags that have an attribute of style, and removing the style attribute.

Removing a specific condition tag

Condition tags are applied to content within the XHTML source code by the special MadCap:conditions attribute. So, for example, you could remove a condition tag of HOLD (defined within the Primary condition tagset) by finding an attribute of MadCap:conditions Primary. HOLD and using a Replace/Action of Remove Attribute MadCap:conditions as shown below.

Screenshot showing Remove HOLD condition

Note that this will not work for instances where another condition has been applied to the same content as the HOLD condition. To remove the HOLD condition from these items, you would have to find every possible combination of HOLD and other conditions (for example: "Primary.HOLD,Primary. AudienceA") and replace the attribute with the other condition on its own (for example: "Primary.AudienceA").

Final observation

I was thinking that it would be useful to be able to automate the process of wrapping an image and its associated caption paragraph within a div, but I couldn't see a way to do this using Find Elements. This is because I would need to be able to find a specific combination of two different tags. Perhaps this will be possible in a future release?

Further reading

Flare's Help on Finding and Replacing Elements

An introduction to regular expressions (O'Reilly)

Learn Regular Expressions with simple, interactive exercises (RegexOne)

 

 

 

Horizontal line

Impact of Coronavirus disease (COVID-19)

Our thoughts are with our peers within the global technical communication community whose lives have been affected by the current pandemic.

We continue to provide training and consulting on Flare, Help+Manual, and a range of user assistance technologies via the Web. As a result of current Europe-wide travel restrictions and official guidance on social distancing, we are unable to offer face-to-face training or consulting until further notice.

During these difficult times and while UK and other European government restrictions remain in place, we are offering the following:

  • A free question and answer service by email, available to all, on any of these topics:
    • Cascading Style Sheets (CSS)
    • All MadCap Software products (including Flare, Central, and Lingo)
    • EC Software's Help+Manual

    (this service is normally only available to past students of UA Europe training courses)

  • Reduced hourly rates for Web-based consulting and training

Please contact us for further information on these services.

Horizontal line

 

Top of page