From c21cccc5917a9c81ed76aca2981889c81402b20e Mon Sep 17 00:00:00 2001 From: anders_k Date: Wed, 30 Nov 2011 22:17:17 +0000 Subject: [PATCH] Halibut: Added \cfg{xhtml-keywordfragments}{BOOL} for named fragments git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6187 212acab6-be3b-0410-9dea-997c60f758d6 --- Docs/src/bin/halibut/bk_xhtml.c | 39 +++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/Docs/src/bin/halibut/bk_xhtml.c b/Docs/src/bin/halibut/bk_xhtml.c index 431c04ba..ecab010b 100644 --- a/Docs/src/bin/halibut/bk_xhtml.c +++ b/Docs/src/bin/halibut/bk_xhtml.c @@ -81,6 +81,7 @@ typedef struct { int suppress_address; xhtmlheadfmt fchapter, *fsect; int nfsect; + int keywordfragments; } xhtmlconfig; /*static void xhtml_level(paragraph *, int); @@ -164,6 +165,7 @@ static xhtmlconfig xhtml_configure(paragraph * source) ret.fsect[1].number_suffix = ustrdup(L" "); ret.rlink_prefix = NULL; ret.rlink_suffix = NULL; + ret.keywordfragments = TRUE; for (; source; source = source->next) { @@ -286,6 +288,9 @@ static xhtmlconfig xhtml_configure(paragraph * source) ret.nfsect = n + 1; } ret.fsect[n].number_suffix = ustrdup(p); + } else if (!ustricmp(source->keyword, L"xhtml-keywordfragments")) + { + ret.keywordfragments = utob(uadv(source->keyword)); } } } @@ -665,6 +670,22 @@ static void xhtml_ponder_layout(paragraph * p) xhtml_fixup_layout(topfile); /* leaf files not at leaf level marked as such */ } +#define NAMEDFRAGMENT_MAXLEN 200 /* More than enough for our usage */ +/* + * Get formated fragment name for html anchor. + * Uses para->keyword if possible, falls back to the ?#.#.# default. + */ +static char* +xhtml_get_fragmentname(const xhtmlsection * section, char * fragmentbuf) +{ + if (conf.keywordfragments) + { + paragraph *para = section->para; + if (para && para->keyword && *para->keyword) return ustrtoa(para->keyword, fragmentbuf, NAMEDFRAGMENT_MAXLEN); + } + return section->fragment; +} + static void xhtml_do_index(); static void xhtml_do_file(xhtmlfile * file); static void xhtml_do_top_file(xhtmlfile * file, paragraph * sourceform); @@ -888,8 +909,9 @@ static void xhtml_do_index_body(FILE * fp) xhtmlsection *sect = xi->sections[i]; if (sect) { + char fragmentbuf[NAMEDFRAGMENT_MAXLEN]; fprintf(fp, "", sect->file->filename, - sect->fragment); + xhtml_get_fragmentname(sect, fragmentbuf)); if (sect->para->kwtext) { xhtml_para(fp, sect->para->kwtext); @@ -1205,6 +1227,7 @@ xhtml_do_contents_section_limit(FILE * fp, xhtmlsection * section, int limit) static int xhtml_add_contents_entry(FILE * fp, xhtmlsection * section, int limit) { + char fragmentbuf[NAMEDFRAGMENT_MAXLEN], *fragment; if (!section || section->level > limit) return FALSE; if (fp == NULL || section->level < 0) @@ -1221,17 +1244,18 @@ xhtml_add_contents_entry(FILE * fp, xhtmlsection * section, int limit) fprintf(fp, "