28.9.3 Surrounding or replacing text with code or macros
To specify code to be invoked before, after, or in place of a paragraph or character format:
1. List the format name in the configuration section appropriate for your output type:
[HTMLCharStyles] for HTML, XML, or HTML-based Help
2. Assign to the format one of the Code* properties listed in Table 28-8. For example:
3. List the same format name in the corresponding [ParaStyleCode*] or [CharStyleCode*] or [AnumCode*] section, and assign to it whatever macros (or code, or both) you want inserted at that point in the resulting output. For example:
This assignment can include any macros of the form <$Macroname> or, for HTML output, <$.\macrofile.htm>.
Note: If the code you assign requires more than one line, you must specify a macro for it, because a key=value entry cannot exceed one line; see §4.4 Understanding the rules for configuration settings.
You can also assign a macro to a format in section [StyleLinkSrc], to provide code for the href attribute of HTML links; see §19.2.4 Specifying link properties with macros.
Table 28-8 Macro code placement properties
For example, to precede each major heading in HTML with an image:
Heading1=<p class="MyImageTag"><$Mona></p>
Later in the configuration file, or in a macro library file:
<img src="smile.jpg" alt="Leonardo's friend Mona" />
The effect in the resulting HTML would be to display the image smile.jpg just before each element mapped from a Heading1 paragraph in your FrameMaker document.
A macro does not have to be well formed by itself; only the end result must be well formed, after all macros are included. For example, suppose you use formats A, B, and C, one after the other, and you want all of them centered in HTML output. You could use these settings to achieve that effect:
You can use [ParaStyleCodeBefore] and [ParaStyleCodeAfter] to place ruled lines or images before and after a heading in RTF output. You can use [ParaStyleCodeStart] to add properties to text in RTF output, such as borders or background shading.
You can use [ParaStyleCodeBefore] and [ParaStyleCodeAfter] to construct a table around a paragraph for HTML, possibly with an image in a cell; this works well for notes or tips. You can also construct a table around a series of paragraphs; see §28.9.4 Converting a dictionary-style list to an HTML table.
You could have a FrameMaker file that contains only a single paragraph, specify CodeReplace for that paragraph format, and assign to it a [ParaStyleCodeReplace] macro; then build the whole HTML output from macros, using macro variables (see §28.3 Using macro variables) to include specific content based on user entries.
§28.9.4 Converting a dictionary-style list to an HTML table
§28.3.7 Creating macro variables from paragraph content
> 28 Working with macros > 28.9 Deploying macros and macro variables > 28.9.3 Surrounding or replacing text with code or macros