summaryrefslogtreecommitdiff
path: root/bk_xhtml.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2002-08-11 16:02:43 +0000
committerSimon Tatham <anakin@pobox.com>2002-08-11 16:02:43 +0000
commitcd0c8ee2f81d98fa842442b5874ae4ff38bfbe85 (patch)
tree490a88364fa6294515a6e58e2bd78eddb906642a /bk_xhtml.c
parentc09f569c688eb1973cda0e1afbb3c520d0a9bb54 (diff)
downloadhalibut-cd0c8ee2f81d98fa842442b5874ae4ff38bfbe85.zip
halibut-cd0c8ee2f81d98fa842442b5874ae4ff38bfbe85.tar.gz
halibut-cd0c8ee2f81d98fa842442b5874ae4ff38bfbe85.tar.bz2
halibut-cd0c8ee2f81d98fa842442b5874ae4ff38bfbe85.tar.xz
Slightly improve the handling of headings in HTML single-file mode.
[originally from svn r1832]
Diffstat (limited to 'bk_xhtml.c')
-rw-r--r--bk_xhtml.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/bk_xhtml.c b/bk_xhtml.c
index 18a7409..fef0779 100644
--- a/bk_xhtml.c
+++ b/bk_xhtml.c
@@ -631,10 +631,12 @@ static int xhtml_para_level(paragraph *p)
{
switch (p->type)
{
+ case para_Title:
+ return 0;
+ break;
case para_UnnumberedChapter:
case para_Chapter:
case para_Appendix:
- case para_Title:
return 1;
break;
/* case para_BiblioCited:
@@ -1449,6 +1451,18 @@ static void xhtml_heading(FILE *fp, paragraph *p)
rdaddsc(&t, ": "); /* FIXME: configurability */
}
xhtml_rdaddwc(&t, text, NULL);
+ /*
+ * If we're outputting in single-file mode, we need to lower
+ * the level of each heading by one, because the overall
+ * document title will be sitting right at the top as an <h1>
+ * and so chapters and sections should start at <h2>.
+ *
+ * Even if not, the document title will come back from
+ * xhtml_para_level() as level zero, so we must increment that
+ * no matter what leaf_level is set to.
+ */
+ if (conf.leaf_level == 0 || level == 0)
+ level++;
fprintf(fp, "<a name=\"%s\"></a><h%i>%s</h%i>\n", fragment, level, t.text, level);
sfree(t.text);
}