X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/halibut/blobdiff_plain/3e82de8fe2753c1859f2f0d2c23456e82154394b..65f95f6cfed6167352f7ca99204211e61da51902:/bk_html.c?ds=inline diff --git a/bk_html.c b/bk_html.c index a4ee338..c58ecf1 100644 --- a/bk_html.c +++ b/bk_html.c @@ -136,6 +136,7 @@ typedef struct { typedef struct { htmlsect *section; char *fragment; + int generated, referenced; } htmlindexref; typedef struct { @@ -214,7 +215,7 @@ static void html_contents_entry(htmloutput *ho, int depth, htmlsect *s, htmlconfig *cfg); static void html_section_title(htmloutput *ho, htmlsect *s, htmlfile *thisfile, keywordlist *keywords, - htmlconfig *cfg); + htmlconfig *cfg, int real); static htmlconfig html_configure(paragraph *source) { htmlconfig ret; @@ -621,6 +622,7 @@ void html_backend(paragraph *sourceform, keywordlist *keywords, indextag *tag; int i; + hr->referenced = hr->generated = FALSE; hr->section = lastsect; { char buf[40]; @@ -994,7 +996,7 @@ void html_backend(paragraph *sourceform, keywordlist *keywords, element_attr(&ho, "name", s->fragment); element_close(&ho, "a"); - html_section_title(&ho, s, f, keywords, &conf); + html_section_title(&ho, s, f, keywords, &conf, TRUE); element_close(&ho, htag); @@ -1223,6 +1225,7 @@ void html_backend(paragraph *sourceform, keywordlist *keywords, html_href(&ho, f, hr->section->file, hr->fragment); + hr->referenced = TRUE; if (p && p->kwtext) html_words(&ho, p->kwtext, MARKUP|LINKS, f, keywords, &conf); @@ -1314,6 +1317,23 @@ void html_backend(paragraph *sourceform, keywordlist *keywords, } /* + * Go through and check that no index fragments were referenced + * without being generated, or indeed vice versa. + * + * (When I actually get round to freeing everything, this can + * probably be the freeing loop as well.) + */ + for (p = sourceform; p; p = p->next) { + word *w; + for (w = p->words; w; w = w->next) + if (w->type == word_IndexRef) { + htmlindexref *hr = (htmlindexref *)w->private_data; + + assert(!hr->referenced == !hr->generated); + } + } + + /* * FIXME: Free all the working data. */ } @@ -1471,6 +1491,7 @@ static void html_words(htmloutput *ho, word *words, int flags, element_open(ho, "a"); element_attr(ho, "name", hr->fragment); element_close(ho, "a"); + hr->generated = TRUE; } break; case word_Normal: @@ -1883,13 +1904,14 @@ static void html_contents_entry(htmloutput *ho, int depth, htmlsect *s, element_open(ho, "li"); html_href(ho, thisfile, s->file, s->fragment); - html_section_title(ho, s, thisfile, keywords, cfg); + html_section_title(ho, s, thisfile, keywords, cfg, FALSE); element_close(ho, "a"); element_close(ho, "li"); } static void html_section_title(htmloutput *ho, htmlsect *s, htmlfile *thisfile, - keywordlist *keywords, htmlconfig *cfg) + keywordlist *keywords, htmlconfig *cfg, + int real) { if (s->title) { sectlevel *sl; @@ -1918,7 +1940,7 @@ static void html_section_title(htmloutput *ho, htmlsect *s, htmlfile *thisfile, html_text(ho, sl->number_suffix); } - html_words(ho, s->title->words, MARKUP, + html_words(ho, s->title->words, real ? ALL : MARKUP, thisfile, keywords, cfg); } else { assert(s->type != NORMAL);