Omni Systems, Inc. |  | Mif2Go User's Guide, Version 55 |  |  |  |  |

> 24 Converting tables to HTML > 24.6 Using macros to control table properties > 24.6.7 Selectively modifying table text with macros: an example

### 24.6.7 Selectively modifying table text with macros: an example

Suppose the following:

• Some columns in your tables have text that you want bold in HTML, even though in FrameMaker the text is not differentiated with a character format or an override.

• The columns in question all have column headings that include the word “Fields”.

• The paragraph format for table body cells is CellBody, and the format for column headings is CellHeading.

To achieve selective bolding, you can use macros to assign different class attributes to paragraph format CellBody, based on the content of each column heading.

Use macro variables to identify table columns

Create two macro variables to hold column numbers; for example, $$ColNum and $$FieldColNum. $$ColNum counts the columns in a table, and $$FieldColNum holds the column number of any column whose heading contains the word “Fields”.

If you are not using table macros for any other purpose, you can use a wildcard to specify the following macros for all tables:

[TableStartMacros]

; Reset $$FieldColNum for each table:

*=<$$FieldColNum = 0>

[TableRowStartMacros]

; Reset $$ColNum for each table row:

*=<$$ColNum = 0>

[TableCellStartMacros]

; Increment $$ColNum for each table column:

*=<$$ColNum++>

See also:

§24.2.3 Using wildcards to specify table sets

§24.6.1 Invoking macros around tables

§28.3 Using macro variables

Assign coding options to table-cell formats

Turn off the HTML paragraph tag that Mif2Go would otherwise automatically assign to CellBody, and specify macro code for both CellBody and CellHeading:

[HTMLParaStyles]

; CellBody formatting will be replaced by macro code:

CellBody=NoPara CodeStart CodeEnd

; CellHeading will hold column-heading content to be checked,

; and also provide the code for checking:

CellHeading=CodeStore CodeAfter

[ParaStyleCodeStart]

; Assign a macro to CellBody, so the code can exceed one line:

CellBody=<$SelectClass>

[ParaStyleCodeEnd]

; Provide a closing tag for the class attribute:

CellBody=</p>

[ParaStyleCodeAfter]

; Use the CodeStore property assigned to CellHeading to

; capture the content of the current CellHeading paragraph,

; and also assign a macro, so the code can exceed one line:

CellHeading=<$$CellHeading><$CheckColHead>

See also:

§21.3.6 Stripping paragraph properties

§28.3.2 Assigning values to macro variables

§28.9.3 Surrounding or replacing text with code or macros

§28.3.7.2 Inserting code with the CodeStore property

Check for columns that need bolding

Use a conditional expression to check the content of each CellHeading paragraph:

[CheckColHead]

; Use string operator "contains" to check the content;

; if the text sought is present, flag the column:

<$_if ($$CellHeading contains "Fields")>

<$$FieldColNum = $$ColNum>

<$_endif>

Select a class attribute based on the column flag

To select a class attribute for CellBody, compare $$ColNum and $$FieldColNum in a conditional expression:

[SelectClass]

<p class="<$_if ($$FieldColNum == $$ColNum)>CellBodyBold

<$_else>CellBody

<$_endif>">

See also:

§28.6.4 Using control structures in expressions

§28.6.5 Specifying substrings in expressions

> 24 Converting tables to HTML > 24.6 Using macros to control table properties > 24.6.7 Selectively modifying table text with macros: an example

| Mif2Go User's Guide: 24.6.6 Capturing table row and column counts with variables |  | Mif2Go User's Guide: 24.7 Converting tables to paragraphs |