summaryrefslogtreecommitdiff
path: root/bk_html.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-07-02 18:45:05 +0000
committerSimon Tatham <anakin@pobox.com>2004-07-02 18:45:05 +0000
commit9b4a26846a2ab033067d27c42f2034e9f74cd02b (patch)
treecb49eb34af5e8ff6259146c4d2766761413e21c1 /bk_html.c
parentd87fabeacea32abba73d67f991f9e523991369c7 (diff)
downloadhalibut-9b4a26846a2ab033067d27c42f2034e9f74cd02b.zip
halibut-9b4a26846a2ab033067d27c42f2034e9f74cd02b.tar.gz
halibut-9b4a26846a2ab033067d27c42f2034e9f74cd02b.tar.bz2
halibut-9b4a26846a2ab033067d27c42f2034e9f74cd02b.tar.xz
Avoid generating an index section if there actually is no index.
[originally from svn r4321]
Diffstat (limited to 'bk_html.c')
-rw-r--r--bk_html.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/bk_html.c b/bk_html.c
index 7ae80b5..23219be 100644
--- a/bk_html.c
+++ b/bk_html.c
@@ -464,6 +464,7 @@ void html_backend(paragraph *sourceform, keywordlist *keywords,
htmlconfig conf;
htmlfilelist files = { NULL, NULL, NULL, NULL, NULL };
htmlsectlist sects = { NULL, NULL }, nonsects = { NULL, NULL };
+ int has_index;
IGNORE(unused);
@@ -532,16 +533,19 @@ void html_backend(paragraph *sourceform, keywordlist *keywords,
sect->fragment);
}
- /* And the index. */
- sect = html_new_sect(&sects, NULL);
- sect->text = NULL;
- sect->type = INDEX;
- sect->parent = topsect;
- html_file_section(&conf, &files, sect, 0); /* peer of chapters */
- sect->fragment = utoa_dup(conf.index_text, CS_ASCII);
- sect->fragment = html_sanitise_fragment(&files, sect->file,
- sect->fragment);
- files.index = sect->file;
+ /* And the index, if we have one. */
+ has_index = (count234(idx->entries) > 0);
+ if (has_index) {
+ sect = html_new_sect(&sects, NULL);
+ sect->text = NULL;
+ sect->type = INDEX;
+ sect->parent = topsect;
+ html_file_section(&conf, &files, sect, 0); /* peer of chapters */
+ sect->fragment = utoa_dup(conf.index_text, CS_ASCII);
+ sect->fragment = html_sanitise_fragment(&files, sect->file,
+ sect->fragment);
+ files.index = sect->file;
+ }
}
/*
@@ -862,13 +866,15 @@ void html_backend(paragraph *sourceform, keywordlist *keywords,
html_text(&ho, conf.nav_separator);
- if (f != files.index) {
- element_open(&ho, "a");
- element_attr(&ho, "href", files.index->filename);
+ if (has_index) {
+ if (f != files.index) {
+ element_open(&ho, "a");
+ element_attr(&ho, "href", files.index->filename);
+ }
+ html_text(&ho, conf.index_text);
+ if (f != files.index)
+ element_close(&ho, "a");
}
- html_text(&ho, conf.index_text);
- if (f != files.index)
- element_close(&ho, "a");
html_text(&ho, conf.nav_separator);