From 6cba4fa3f6c02db9994d6b6234f2ae5007839a5d Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 23 Mar 2004 20:10:23 +0000 Subject: Man-page back end for Halibut. Also, a couple of additional markup features commonly used in man pages: (a) the ability to nest paragraph breaks, code paragraphs and other lists inside list items, and (b) description lists as normally used in man pages to describe command-line options. [originally from svn r3954] --- bk_xhtml.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 13 deletions(-) (limited to '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); } /* -- cgit v1.1