/* start list, have to convert from *TeX types... */
static void html_list(const tok_seq::tok *t, const docfmt *fmt, FILE *out,
void *d)
{
const struct list_info *linf;
const char *s;
fmt=fmt;
d=d;
linf=ltype_info(t->data.d);
if (linf==NULL)
{
cerr<<"Unknown list type "<<t->data.d<<" treated as bulleted list\n";
s="<UL>";
}
else
{
s=linf->start;
}
fprintf(out, "\n%s\n", s);
}
/* end list, have to convert from *TeX types... */
static void html_end_list(const tok_seq::tok *t, const docfmt *fmt, FILE *out,
void *d)
{
const struct list_info *linf;
const char *s;
fmt=fmt;
d=d;
fmt=fmt;
d=d;
linf=ltype_info(t->data.d);
if (linf==NULL)
{
cerr<<"Unknown list type "<<t->data.d<<" treated as bulleted list\n";
s="</UL>";
}
else
s=linf->end;
fprintf(out, "\n%s\n", s);
}
/*
* Paragraphs are easy, but get complicated due to need to work out
* which things are actually chapter headings, etc
*/
static void fold_para(const tok_seq::tok *tok, const docfmt *fmt, FILE *out,
void *d)
{
tblock *b, *ts, op;
const char *s, *t, *pt, *unit_html="P";
struct html_data *dp;
int has_num, i, j;
struct unit_number u_num;
/* Even this much is under 100%!! */
pt=(tok->data.d);
if (*pt=='\0' && dp->list_flg==1)
return;
if (dp->last_tc != NULL)
{
if (strcmp(dp->last_tc, pt)==0)
{
unit_html=sects[dp->unit_d.unit_type];
}
else
{
s=dp->last_tc+strlen(dp->last_tc)-strlen(pt);
if (strcmp(s, pt)==0)
{
/* Find type */
for (i=0; i<(int) N(sects_english); i++)
{
if (strncasecmp(dp->last_tc, sects_english[i],
strlen(sects_english[i]))==0)
break;
}
t = dp->last_tc+strlen(sects_english[i]);
has_num = get_part_num(t,s);
unit_html=sects[i]; // Set the section type
/* Update the control data */
if (dp->unit_d.unit_number[i]==-1)
{
dp->unit_d.unit_number[i]=(has_num==-1) ? 1 : has_num;
for (j=i+1; j<(int) N(sects); j++)
dp->unit_d.unit_number[j]=0;
}
if (i<(int) N(sects)-1)
dp->unit_d.unit_type=i+1;
else
dp->unit_d.unit_type=i;
}
}
free((void *) dp->last_tc);
dp->last_tc=NULL;
}
else
{
if (dp->list_flg)
{
op.add("<Li>");
}
else
{
if (strlen(pt)>0 && strlen(pt)<PAR_TRESHOLD_LEN)
{
if (strcasecmp(pt,"Appendix")==0)
{
dp->unit_d.unit_type=
(dp->unit_d.unit_number[0]==-1) ? 1 : 0;
/* Output the heading level */
unit_html=sects[dp->unit_d.unit_type];
for (j=dp->unit_d.unit_type+1; j<(int) N(sects); j++)
dp->unit_d.unit_number[j]=0;
}
else if (strcasecmp(pt,"Bibliography")==0)
{
dp->unit_d.unit_type=
(dp->unit_d.unit_number[0]==-1) ? 1 : 0;
for (j=dp->unit_d.unit_type+1; j<(int) N(sects); j++)
dp->unit_d.unit_number[j]=0;
}
else
{
u_num=n_unit_probe(pt, &(dp->unit_d));
if (u_num.unit_num!=-1)
{
i=u_num.offset;
unit_html=sects[u_num.unit_num];
}
}
}
}
dp->list_flg=0;
}
/* Record the unit type started */
dp->unit_html=unit_html;
/* Insert the start tag and eneter paragraoh if not in one */
if (!dp->par_flg)
{
dp->par_flg = 1;
op.add("<");
op.add(unit_html);
op.add('>');
}
/* Add the text */
ts = map_string(pt, html_map);
op.add(*ts);
delete(ts);
/* fold the line */
b = word_wrap(op, "\n", "\n", fmt->maxline, 0);
fputs((*b), out);
delete(b);
}
/* End of paragraph, outputs the end tag */
static void end_para(const tok_seq::tok *tok, const docfmt *fmt, FILE *out,
void *d)
{
struct html_data *dp;