22.7.11 Overriding CSS class for selected paragraphs
Paragraphs that have distinct purposes in your document should have distinct FrameMaker format names, even if they share the same print format. However, if your document does contain paragraphs with the same format name that need different CSS classes, you can use Code markers to flag those paragraphs, and assign a different class with a macro.
For example, suppose most of your Heading 2 paragraphs are assigned CSS class Heading2, but a few Heading 2 paragraphs need one of three other classes: About, Configuration, or Procedure. You can surround all Heading 2 paragraphs with code to hold the HTML tags and class assignments:
Heading 2=NoPara CodeBefore CodeAfter
The starting H2 tag assigns a class whose value is computed by macro $UseH2Class:
Heading 2=<H2 class="<$UseH2Class>">
The closing H2 tag follows the paragraph:
Macro $UseH2Class checks the value of macro variable $$h2class to determine which class to assign:
<$_if ($$h2class is "A")>About\
<$_elseif ($$h2class is "C")>Configuration\
<$_elseif ($$h2class is "P")>Procedure\
Macro variable $$h2class is initialized (and always reset) to a value that results in assigning the default class, Heading2 (via the $_else clause in macro $UseH2Class):
To set $$h2class for a paragraph that needs a non-default class, you would insert a Code marker in the paragraph that precedes each such paragraph. The content of the marker would look like this:
To assign a non-default class to the very first paragraph in a FrameMaker file, you would have to create a chapter-specific configuration file, filename.ini, for that FrameMaker file, with content (for example):
See §33.1.1 Providing configuration files for individual chapters.
§29 Working with FrameMaker markers
§33 Overriding configuration settings
> 22 Setting up CSS for HTML > 22.7 Assigning CSS classes > 22.7.11 Overriding CSS class for selected paragraphs