Formatting/markup in variables?

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

Moderators: Alexander Halser, Tim Green

Post Reply
User avatar
Ed Hawco
Posts: 165
Joined: Thu Nov 07, 2013 5:50 pm
Location: Montreal
Contact:

Formatting/markup in variables?

Unread post by Ed Hawco »

Is there some way to add formatting or markup tags inside a variable?

Use case: I have two topics that use a snippet, but the second one has a extra phrase that could use some formatting. Example:

(In topic 1)
Trees in the garden bear fruit every year, such as red apples.

(In topic 2)
Trees in the garden bear fruit every year, such as red apples and yellow pears.

The snippet is:
Trees in the garden bear fruit every year, such as red apples<%CUSTOM-FRUIT-VARIABLE%>.

In topic 1, the <%CUSTOM-FRUIT-VARIABLE%> has no definition. In topic 2, the <%CUSTOM-FRUIT-VARIABLE%> is:
and yellow pears

THUS: is there a way to put the word "pears" in the topic variable definition for <%CUSTOM-FRUIT-VARIABLE%> in bold? I tried straight-up HTML tags, but that didn't work...
e
d
============================================
Ed Hawco
User avatar
Martin Wynne
Posts: 2656
Joined: Mon May 12, 2003 3:21 pm
Location: West of the Severn, UK

Re: Formatting/markup in variables?

Unread post by Martin Wynne »

Hi Ed,

At first sight, the easiest solution would be to use 2 custom variables.

<%CUSTOM-FRUIT-COLOUR-VARIABLE%> = and yellow
<%CUSTOM-FRUIT-TYPE-VARIABLE%> = pears

If you make <%CUSTOM-FRUIT-TYPE-VARIABLE%> bold in the snippet text, it will appear bold when replaced.

regards,

Martin.
User avatar
Tim Green
Site Admin
Posts: 23181
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Formatting/markup in variables?

Unread post by Tim Green »

I tried straight-up HTML tags, but that didn't work...
No, because even HTML variables will not use the HTML code in topics. They will only insert HTML code in templates, or if they are enclosed in HTML code objects. There are two ways to do this:

1) HTML variable enclosed in an HTML code object:

This method only works for HTML output and it's really more complicated than it's worth: Define the variables as HTML variables, and define them like this:

Code: Select all

Trees in the garden bear fruit every year, such as red <strong>apples</strong>.
Then, instead of inserting them directly, insert them in an HTML code object with the Code Object tool in Write > Insert Object, and remember to check the box for not enclosing the object in a block element.

2) Define a snippet instead of a variable

This method works everywhere, but it isn't variable like variables. So if you want to have different versions in different builds you need to combine it with conditional tags. Instead of defining a variable, define a snippet in an external file, making sure to choose the option that the snippet doesn't start a new paragraph. Then you can have any kind of formatting you like in the snippet:

http://www.helpandmanual.com/help/index ... ippets.htm
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.
Post Reply