28.9.4.4 Making it work everywhere
At this point (after §28.9.4.3 Putting it all together) you have most of the configuration settings, HTML code, and macro logic you need to create an HTML table from a dictionary-style list. Now you must make sure the table ends gracefully in all contexts.
The <$TableEnd> macro is defined with a condition, so that it does nothing unless a table is being generated from a dictionary list. This makes it safe to assign to any text format that is not part of a dictionary list. But what if the list is inside a table in FrameMaker, or is immediately followed by a table, or is at the very end of the file? You must make sure the generated table is “tied off” before tags are required for an enclosing or following table, because those tags must precede any non-list paragraphs that would otherwise end the generated table.
You must meet the following challenges:
End the table before starting another table
End the table before ending an enclosing cell
End the table if the file ends.
End the table before starting another table
To make sure the dictionary-list table ends before another table begins:
; TableID = macro to put before table start, top title or indent
a_table_group=<$TableEnd><DIV class="twide">
; TableID = macro to put after table end or bottom title
The call to <$TableEnd> comes before any other code you assign to a particular table (or table group); and before any other table. This ensures that the generated table ends before another table starts. You can insert the <$TableEnd> macro in several other places, to position it with respect to other tables; see §24.6.1 Invoking macros around tables.
End the table before ending an enclosing cell
To handle the case where the generated table is inside a cell of another table (in FrameMaker), you must invoke <$TableEnd> at the end of every FrameMaker table cell:
This setting applies to the cells of an enclosing table in FrameMaker, not to HTML table cells that are being generated.
End the table if the file ends
What if a list is at the end of a file, so there is no text, table, or other construct immediately following the generated table? You can invoke the same table-ending macro here:
See §18.5.2 Assigning code to [Inserts] keywords for splits and extracts.
> 28 Working with macros > 28.9 Deploying macros and macro variables > 28.9.4 Converting a dictionary-style list to an HTML table > 28.9.4.4 Making it work everywhere