From c8c7926bf373a8711473a65c078bea6c3783ddb8 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 31 Mar 2004 17:28:55 +0000 Subject: [PATCH] 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... git-svn-id: svn://svn.tartarus.org/sgt/halibut@4010 cda61777-01e9-0310-a592-d414129be87e --- bk_xhtml.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/bk_xhtml.c b/bk_xhtml.c index 4cbe1d6..02e2a32 100644 --- a/bk_xhtml.c +++ b/bk_xhtml.c @@ -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, "\n"); + fprintf(fp, "\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, "\n"); + fprintf(fp, "\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, "\n"); - } - while (last_level < section->level) { + if (last_level > section->level) { + while (last_level > section->level) { + last_level--; + fprintf(fp, "\n"); + } + fprintf(fp, "\n"); + } else if (last_level < section->level) { + assert(last_level == section->level - 1); last_level++; fprintf(fp, "