Nesting Formatting Codes


[Home][Index][Previous][Next]
Formatting code strings (other than "{$IMG" codes and algebraic codes) may have other formatting codes nested within them. In other words, in the text color formatting code:

{$COLOR=value text}

"text" can contain other formatting codes.

For example, to create bold italics, you could use:

{$STYLE=BOLD {$STYLE=ITALIC This is in bold italics.}}

or, to highlight text in underlined, red, Courier font, you could use:

{$STYLE=UNDER {$COLOR=red {$FONT=Courier This 
text is in underlined Courier font, colored red.}}}
 

All of the formatting strings do not have to begin in the same place. The following code string produces "This is red but this is blue and this is red again."

{$COLOR=red This is red {$COLOR=blue but this is blue} 
and this is red again.} 

Note that formatting codes must be nested completely within the containing format string - overlapping is not allowed.

It is not permitted to nest formatting strings inside image code ("{$IMG") strings. Why would you want to?), but image code strings may be nested inside other formatting strings. Format code strings must begin and end in the same text string - they cannot span a line break.


Example:

\TITLE
Nested Format Codes Demo
\TF A T
This is plain text, but 
{$STYLE=BOLD {$STYLE=ITALIC this is in bold italics.}}
This has {$COLOR=red some red text with 
{$SIZE=18 {$COLOR=blue some big blue text }}
mixed into} the middle of it.
This line has some {$FONT=Courier {$STYLE=ITALIC 
Courier font in italics.}} in it.

The applet below runs this question file:

You need a Java-enabled browser to take this quiz.


A Common Mistake:

A common mistake that can be difficult to figure out is to forget the "one-or-more spaces" that must follow the "value" in a format code. For example:

This line has some {$FONT=Courier{$STYLE=ITALIC text}}

would cause a puzzling error message like:

Error Parsing Question 1:
Text Font expected at Courier in ... 

Isn't "Courier" a valid font? Yes, it is. The problem is that there is no space between "Courier" and "{". The following works:

This line has some {$FONT=Courier {$STYLE=ITALIC text}}

[Home][Index][Previous][Next]
copyright © 1998 by Jerry L. Stanbrough - all rights reserved.
last update May 12, 1999 by JL Stanbrough (jstanbro@venus.net)