Omni Systems, Inc.

  

Mif2Go User's Guide, Version 55

  

Valid HTML 4.01!

 

Made with Mif2Go

14 Converting to generic XML > 14.8 Converting index entries to generic XML > 14.8.2 Defining macros to process index content > 14.8.2.3 Detecting colons used as text or punctuation


14.8.2.3 Detecting colons used as text or punctuation

Suppose some FrameMaker index entries include colons as punctuation or as part of the text, instead of as level separators; that is, some colons are escaped thus \: in index markers. You could modify macro [ProcIXtext] as follows, to distinguish between colon-as-text and colon-as-separator:

 

[ProcIXtext]

 

1

<$$IXlevel = 1>

 

2

<$_while ($$IXtext)>

 

3

   <index<$$IXlevel>>

Opening XML tag

4

   <$$IXpart = ($$IXtext before ":")>

 

5

   <$_if (($$IXpart last 2) is "\\")>

Check for colon-as-text

6

      <$ProcIXLitColon>

Call another macro

7

      <$_endif>

 

8

   <$$IXpart>

Text output

9

   <$$IXpart = ($$IXtext after ":")>

 

10

   <$$IXtext = $$IXpart>

 

11

   </index<$$IXlevel>>

Closing XML tag

12

   <$$IXlevel++>

 

13

   <$_endwhile>

 

You need a double backslash \\ on line 5, because that is how an escaped colon in a FrameMaker marker is represented internally by Mif2Go DCL.

Index-entry text that does not include a colon-as-text is output on line 8, and surrounding XML tags are output on line 3 and line 11.

Process colon as punctuation

A second macro [ProcIXLitColon] has to be invoked on line 6, because you cannot nest a <$_while> inside another <$_while> in the same macro; see §28.6.4.3 Using loop structures:

 

[ProcIXLitColon]

 

1

<$_while (($$IXpart last 2) is "\\")>

 

2

   <$($$IXpart first (($$IXpart length) - 2)) as %s>:

Text output

3

   <$$IXpart = ($$IXtext after ":")>

 

4

   <$$IXtext = $$IXpart>

 

5

   <$$IXpart = ($$IXtext before ":")>

 

6

   <$_endwhile>

 

Index-entry content at the current level, up to the colon-as-text, and then the text colon itself, are output on line 2 of [ProcIXLitColon].



14 Converting to generic XML > 14.8 Converting index entries to generic XML > 14.8.2 Defining macros to process index content > 14.8.2.3 Detecting colons used as text or punctuation