rem: case ENDSUBSECTION:	printf("\n</refsect2>"); break;
add: case ENDSUBSECTION:		if (fPara) { printf("\n</para>"); fPara=0; } printf("\n</refsect2>"); break;
context: XML(enum command cmd) {	static int pre=0;	int i;	int lasttoc;	char *p;	static int fRefEntry=0;	static int fRefPurpose=0;	/*static char *bads => XML doesn't backslash-quote metacharacters *//**/	/* always respond to these signals */	switch (cmd) {	   case CHARLQUOTE: case CHARRQUOTE: printf("&quot;"); break;	   case CHARBULLET: printf("&bull;"); break;	   case CHARDAGGER: printf("&dagger;"); break;	   case CHARPLUSMINUS: printf("&plusmn;"); break; 	   case CHARCOPYR: printf("&copy;"); break; 	   case CHARNOT: printf("&not;"); break; 	   case CHARMUL: printf("&times;"); break; 	   case CHARDIV: printf("&divide;"); break;	   case CHARAMP: printf("&amp;"); break;	   case CHARDASH:		if (sectheadid==NAME && !fRefPurpose) {			printf("</refname><refpurpose>");			fRefPurpose=1;		} else putchar('-');		break;	   case CHARBACKSLASH: putchar('\\'); break;	   case CHARGT: printf("&gt;"); break;	   case CHARLT: printf("&lt;"); break;	   case CHARLSQUOTE:	   case CHARRSQUOTE:	   case CHARPERIOD:	   case CHARTAB:	   case CHARHAT:	   case CHARVBAR:	   case CHARNBSP: 	   case CHARCENT: 	   case CHARSECT: 	   case CHARREGTM: 	   case CHARDEG: 	   case CHARACUTE: 	   case CHAR14: 	   case CHAR12: 	   case CHAR34: 		 putchar(cmd); 		 break;	   default:		break;	}	/* while in pre mode... */	if (pre) {		switch (cmd) {		   case ENDLINE:	I=0; CurLine++; if (!fPara && scnt) putchar(' '); break;		   case ENDTABLE:			if (fSource) printf("</table>\n");			else { printf("</literallayout>\n"); pre=0; fQS=fIQS=fPara=1; }			break;		   default:			/* nothing */			break;		}		return;	}	/* usual operation */	switch (cmd) {	   case BEGINDOC:		printf("\n<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\"\n");		printf("  \"%s\">\n", DOCBOOKPATH);		printf("<!--\n\n\tI am looking for help to finish DocBook XML.\n\n-->\n");		printf("<!-- %s\n", PROVENANCE);		printf("     %s -->\n\n",HOME);		/* better title possible? */		for (p=manName; *p; p++) *p = tolower(*p);		printf("<refentry id='%s.%s'>\n", manName, manSect);		printf("<refmeta>\n<refentrytitle>%s</refentrytitle>\n", manName);		printf("<manvolnum>%s</manvolnum>\n</refmeta>\n\n", manSect);		I=0;		break;	   case ENDDOC:		/* header and footer wanted? */		if (fHeadfoot) {			printf("\n<refsect1>\n<title>%s</title>\n", HEADERANDFOOTER);			for (i=0; i<CRUFTS; i++) if (*cruft[i]) printf("<para>%s</para>\n", cruft[i]);			printf("\n</refsect1>");		}		/* table of contents, such as found in HTML, can be generated automatically by XML software */		printf("</refentry>\n");		break;	   case BEGINBODY:		 if (fPara) printf("\n</para>");		 printf("<para>"); fPara = 1;		 break;	   case ENDBODY:		 if (fRefPurpose) { printf("</refpurpose>"); fRefPurpose=0; }		 else { printf("\n</para>"); fPara=0; }		 break;	   case BEGINCOMMENT: printf("\n<!--\n"); break;	   case ENDCOMMENT: printf("\n-->\n"); break;	   case COMMENTLINE: break;	   case BEGINSECTHEAD:	   case BEGINSUBSECTHEAD:		if (sectheadid != NAME && sectheadid != SYNOPSIS) printf("<title>");		break;	   case ENDSECTHEAD:	   case ENDSUBSECTHEAD:		if (sectheadid == NAME) printf("--><refname>");		else if (sectheadid == SYNOPSIS) {}		else { printf("</title>\n<para>"); fPara=1; }		break;	   case BEGINSECTION:		if (sectheadid==NAME) printf("<refnamediv><!--\n");			/*printf("<RefEntry>");  -- do lotsa parsing here for RefName, RefPurpose*/		else if (sectheadid==SYNOPSIS) printf("<refsynopsisdiv>\n<cmdsynopsis><!--\n");		else printf("\n<refsect1>\n");		break;	   case ENDSECTION:		if (sectheadid==NAME) {		  if (fRefPurpose) { printf("</refpurpose>"); fRefPurpose=0; }		  printf("\n</refnamediv>\n\n");		} else if (sectheadid==SYNOPSIS) printf("\n</cmdsynopsis>\n</refsynopsisdiv>\n");		else {		  if (fPara) { printf("\n</para>"); fPara=0; }		  printf("\n</refsect1>\n");		}		break;	   case BEGINSUBSECTION:	printf("\n<refsect2>"); break;	   case ENDSUBSECTION:	printf("\n</refsect2>"); break;	   /* need to update this for enumerated and plain lists */	   case BEGINBULPAIR:	printf("<variablelist>\n"); break;	   case ENDBULPAIR:		printf("</variablelist>\n"); break;	   case BEGINBULLET:	printf("<varlistentry><term>"); break;	   case ENDBULLET:		printf("</term>\n"); break;	   case BEGINBULTXT:	printf("<listitem>\n<para>"); break;	   case ENDBULTXT:		printf("\n</para></listitem></varlistentry>\n"); break;	   case BEGINLINE:		/* remember, get BEGINBODY call at start of paragraph */		if (fRefEntry) {			if (fRefPurpose) {				for (p=plain; *p!='-'; p++) {					/* nothing?! */				}			}		}		break;	   case ENDLINE:		/*if (fCodeline) { fIQS=1; fCodeline=0; }*/		if (fCodeline) { printf("</code>"); fCodeline=0; } /*  */		I=0; CurLine++; if (!fPara && scnt) printf("<sbr/>"); else putchar(' ');		break;	   case SHORTLINE:		if (fCodeline) { printf("</code>"); fCodeline=0; }		if (!fIP && !fPara) printf("<sbr/>\n");		break;	   case BEGINTABLE:		if (fSource) printf("<table>\n");		else { printf("<literallayout>\n"); pre=1; fQS=fIQS=fPara=0; }		break;	   case ENDTABLE:		if (fSource) printf("</table>\n");		else { printf("</literallayout>\n"); pre=0; fQS=fIQS=fPara=1; }		break;	   case BEGINTABLELINE:		printf("<row>"); break;	   case ENDTABLELINE:		printf("</row>\n"); break;	   case BEGINTABLEENTRY:		printf("<entry>"); break;	   case ENDTABLEENTRY:		printf("</entry>"); break;	   case BEGININDENT: case ENDINDENT: break;	   case FONTSIZE:		break;	   /* have to make some guess about bold and italics */	   case BEGINBOLD:		if (sectheadid==SYNOPSIS) printf("-->"); 					printf("<command>"); break;	   case ENDBOLD:		printf("</command>"); break;	   case BEGINITALICS:	printf("<emphasis>"); break;	/* could be literal or arg */	   case ENDITALICS:		printf("</emphasis>"); break;	   case BEGINBOLDITALICS: case BEGINCODE:	printf("<literal>"); break;	   case ENDBOLDITALICS: case ENDCODE:	printf("</literal>"); break;	   case BEGINMANREF:		manrefextract(hitxt);		if (fmanRef) { printf("<link linkend='"); printf(href, manrefname, manrefsect); printf("'>"); }		break;	   case ENDMANREF:		if (fmanRef) printf("</link>");		break;	   case HR:	   case BEGINSC: case ENDSC:	   case BEGINY: case ENDY:	   case BEGINHEADER: case ENDHEADER:	   case BEGINFOOTER: case ENDFOOTER:	   case CHANGEBAR:		/* nothing */		break;	   default:		DefaultPara(cmd);	}}