X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/halibut/blobdiff_plain/7cf305b7b9110585d31cdaad8de89411c688a465..7136a6c7f094fa423c48ec319748c4fd7e1fa645:/bk_xhtml.c diff --git a/bk_xhtml.c b/bk_xhtml.c index 140e2dd..053bf33 100644 --- a/bk_xhtml.c +++ b/bk_xhtml.c @@ -1076,14 +1076,15 @@ static void xhtml_do_sections(FILE *fp, xhtmlsection *sections) /* Write this list of paragraphs. Close off all lists at the end. */ static void xhtml_do_paras(FILE *fp, paragraph *p) { - int last_type = -1, first=TRUE; + int last_type = -1, ptype, first=TRUE; + stack lcont_stack = stk_new(); if (!p) return; /* for (; p && (xhtml_para_level(p)>limit || xhtml_para_level(p)==-1 || first); p=p->next) {*/ for (; p && (xhtml_para_level(p)==-1 || first); p=p->next) { first=FALSE; - switch (p->type) + switch (ptype = p->type) { /* * Things we ignore because we've already processed them or @@ -1123,8 +1124,29 @@ static void xhtml_do_paras(FILE *fp, paragraph *p) fprintf(fp, "

\n"); break; + case para_LcontPush: + { + int *p; + p = mknew(int); + *p = last_type; + stk_push(lcont_stack, p); + last_type = para_Normal; + } + break; + case para_LcontPop: + { + int *p = stk_pop(lcont_stack); + assert(p); + ptype = last_type = *p; + sfree(p); + goto closeofflist; /* ick */ + } + break; + case para_Bullet: case para_NumberedList: + case para_Description: + case para_DescribedThing: case para_BiblioCited: if (last_type!=p->type) { /* start up list if necessary */ @@ -1132,41 +1154,62 @@ static void xhtml_do_paras(FILE *fp, paragraph *p) fprintf(fp, "\n"); - } else if (p->type == para_NumberedList) { + } else if (ptype == para_NumberedList) { fprintf(fp, "\n"); - } else if (p->type == para_BiblioCited) { + } else if (ptype == para_BiblioCited || + ptype == para_Description || + ptype == para_DescribedThing) { fprintf(fp, "\n"); } } @@ -1177,8 +1220,10 @@ static void xhtml_do_paras(FILE *fp, paragraph *p) xhtml_codepara(fp, p->words); break; } - last_type = p->type; + last_type = ptype; } + + stk_free(lcont_stack); } /*