diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-03-31 17:28:55 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-03-31 17:28:55 +0000 |
| commit | 83fdced76545958b31ef549cfcb37f6f57bfc5bb (patch) | |
| tree | 11bce072bc9a53e25f6c2a8d546c21049452b07b /bk_xhtml.c | |
| parent | 7c4409fdcf11bbbda4a0b1d9d3c293d8808f4f04 (diff) | |
| download | halibut-83fdced76545958b31ef549cfcb37f6f57bfc5bb.zip halibut-83fdced76545958b31ef549cfcb37f6f57bfc5bb.tar.gz halibut-83fdced76545958b31ef549cfcb37f6f57bfc5bb.tar.bz2 halibut-83fdced76545958b31ef549cfcb37f6f57bfc5bb.tar.xz | |
After so much fuss was made about this being an _XHTML_ back end
rather than merely HTML, I thought it might be instructive to run it
through the W3C's XHTML validator. Consequent changes in this
checkin...
[originally from svn r4010]
Diffstat (limited to 'bk_xhtml.c')
| -rw-r--r-- | bk_xhtml.c | 40 |
1 files changed, 25 insertions, 15 deletions
@@ -112,7 +112,7 @@ static xhtmlsection *topsection; static paragraph *sourceparas; static xhtmlfile *lastfile; static xhtmlfile *xhtml_last_file = NULL; -static int last_level=-1; +static int last_level=-1, start_level; static xhtmlsection *currentsection; static xhtmlconfig xhtml_configure(paragraph *source) @@ -933,7 +933,7 @@ static void xhtml_utostr(wchar_t *in, char **out) */ static int xhtml_do_contents(FILE *fp, xhtmlfile *file) { - int level, limit, start_level, count = 0; + int level, limit, count = 0; if (!file) return 0; @@ -947,7 +947,7 @@ static int xhtml_do_contents(FILE *fp, xhtmlfile *file) if (fp!=NULL) { while (last_level > start_level) { last_level--; - fprintf(fp, "</ul>\n"); + fprintf(fp, "</li></ul>\n"); } } return count; @@ -969,7 +969,7 @@ static int xhtml_do_naked_contents(FILE *fp, xhtmlfile *file) if (fp!=NULL) { while (last_level > start_level) { last_level--; - fprintf(fp, "</ul>\n"); + fprintf(fp, "</li></ul>\n"); } } return count; @@ -1037,13 +1037,18 @@ static int xhtml_add_contents_entry(FILE *fp, xhtmlsection *section, int limit) return FALSE; if (fp==NULL || section->level < 0) return TRUE; - while (last_level > section->level) { - last_level--; - fprintf(fp, "</ul>\n"); - } - while (last_level < section->level) { + if (last_level > section->level) { + while (last_level > section->level) { + last_level--; + fprintf(fp, "</li></ul>\n"); + } + fprintf(fp, "</li>\n"); + } else if (last_level < section->level) { + assert(last_level == section->level - 1); last_level++; fprintf(fp, "<ul>\n"); + } else { + fprintf(fp, "</li>\n"); } fprintf(fp, "<li><a href=\"%s#%s\">", section->file->filename, section->fragment); if (section->para->kwtext) { @@ -1055,7 +1060,7 @@ static int xhtml_add_contents_entry(FILE *fp, xhtmlsection *section, int limit) if (section->para->words) { xhtml_para(fp, section->para->words, FALSE); } - fprintf(fp, "</a></li>\n"); + fprintf(fp, "</a>\n"); return TRUE; } @@ -1154,7 +1159,9 @@ static void xhtml_do_paras(FILE *fp, paragraph *p, paragraph *end, case para_Description: case para_DescribedThing: case para_BiblioCited: - if (last_type!=p->type) { + if (last_type!=p->type && + !(last_type==para_DescribedThing && p->type==para_Description) && + !(last_type==para_Description && p->type==para_DescribedThing)) { /* start up list if necessary */ if (p->type == para_Bullet) { fprintf(fp, "<ul>\n"); @@ -1187,9 +1194,9 @@ static void xhtml_do_paras(FILE *fp, paragraph *p, paragraph *end, closeofflist: if (ptype == para_BiblioCited) { fprintf(fp, "</dd>\n"); - } else if (p->type == para_DescribedThing) { + } else if (ptype == para_DescribedThing) { fprintf(fp, "</dt>"); - } else if (p->type == para_Description) { + } else if (ptype == para_Description) { fprintf(fp, "</dd>"); } else if (ptype == para_Bullet || ptype == para_NumberedList) { fprintf(fp, "</li>"); @@ -1203,7 +1210,10 @@ static void xhtml_do_paras(FILE *fp, paragraph *p, paragraph *end, int close_off=FALSE; /* if (p2 && (xhtml_para_level(p2)>limit || xhtml_para_level(p2)==-1)) {*/ if (p2 && xhtml_para_level(p2)==-1) { - if (p2->type != ptype && p2->type != para_LcontPush) + if (p2->type != ptype && + !(p2->type==para_DescribedThing && ptype==para_Description) && + !(p2->type==para_Description && ptype==para_DescribedThing) && + p2->type != para_LcontPush) close_off=TRUE; } else { close_off=TRUE; @@ -1303,7 +1313,7 @@ static void xhtml_versionid(FILE *fp, word *text, int started) rdaddc(&t, ']'); /* FIXME: configurability */ if (started) - fprintf(fp, "<br>\n"); + fprintf(fp, "<br />\n"); fprintf(fp, "%s\n", t.text); sfree(t.text); } |