diff --git a/Docs/src/bin/halibut.exe b/Docs/src/bin/halibut.exe index 834e414e..2e69731a 100644 Binary files a/Docs/src/bin/halibut.exe and b/Docs/src/bin/halibut.exe differ diff --git a/Docs/src/bin/halibut/bk_xhtml.c b/Docs/src/bin/halibut/bk_xhtml.c index 25b97afb..c90db812 100644 --- a/Docs/src/bin/halibut/bk_xhtml.c +++ b/Docs/src/bin/halibut/bk_xhtml.c @@ -76,6 +76,8 @@ typedef struct { wchar_t *author, *description; wchar_t *head_end, *body, *body_start, *body_end, *address_start, *address_end, *nav_attrs; + wchar_t *rlink_prefix, *rlink_suffix; + wchar_t *chm_toc_file, *chm_ind_file; int suppress_address; xhtmlheadfmt fchapter, *fsect; int nfsect; @@ -101,6 +103,8 @@ static void xhtml_para(FILE *, word *); static void xhtml_codepara(FILE *, word *); static void xhtml_heading(FILE *, paragraph *); +static void chm_doheader(FILE *, word *); +static void chm_dofooter(FILE *); /* File-global variables are much easier than passing these things * all over the place. Evil, but easier. We can replace this with a single * structure at some point. @@ -115,6 +119,9 @@ static xhtmlfile *lastfile; static xhtmlfile *xhtml_last_file = NULL; static int last_level = -1; static xhtmlsection *currentsection; +static FILE* chm_toc = NULL; +static FILE* chm_ind = NULL; + static xhtmlconfig xhtml_configure(paragraph * source) { @@ -143,7 +150,10 @@ static xhtmlconfig xhtml_configure(paragraph * source) ret.address_end = NULL; ret.nav_attrs = NULL; ret.suppress_address = FALSE; - + ret.chm_toc_file = NULL; + ret.chm_ind_file = NULL; + chm_toc = NULL; + chm_ind = NULL; ret.fchapter.just_numbers = FALSE; ret.fchapter.number_suffix = ustrdup(L": "); ret.nfsect = 2; @@ -152,6 +162,8 @@ static xhtmlconfig xhtml_configure(paragraph * source) ret.fsect[0].number_suffix = ustrdup(L": "); ret.fsect[1].just_numbers = TRUE; ret.fsect[1].number_suffix = ustrdup(L" "); + ret.rlink_prefix = NULL; + ret.rlink_suffix = NULL; for (; source; source = source->next) { @@ -195,6 +207,12 @@ static xhtmlconfig xhtml_configure(paragraph * source) } else if (!ustricmp(source->keyword, L"xhtml-author")) { ret.author = uadv(source->keyword); + } else if (!ustricmp(source->keyword, L"chm-toc-file")) + { + ret.chm_toc_file = uadv(source->keyword); + } else if (!ustricmp(source->keyword, L"chm-ind-file")) + { + ret.chm_ind_file = uadv(source->keyword); } else if (!ustricmp(source->keyword, L"xhtml-description")) { ret.description = uadv(source->keyword); @@ -226,6 +244,12 @@ static xhtmlconfig xhtml_configure(paragraph * source) } else if (!ustricmp(source->keyword, L"xhtml-chapter-suffix")) { ret.fchapter.number_suffix = ustrdup(uadv(source->keyword)); + } else if (!ustricmp(source->keyword, L"xhtml-rlink-prefix")) + { + ret.rlink_prefix = uadv(source->keyword); + } else if (!ustricmp(source->keyword, L"xhtml-rlink-suffix")) + { + ret.rlink_suffix = uadv(source->keyword); } else if (!ustricmp(source->keyword, L"xhtml-section-numeric")) { wchar_t *p = uadv(source->keyword); @@ -646,11 +670,8 @@ static void xhtml_do_file(xhtmlfile * file); static void xhtml_do_top_file(xhtmlfile * file, paragraph * sourceform); static void xhtml_do_paras(FILE * fp, paragraph * p); static int xhtml_do_contents_limit(FILE * fp, xhtmlfile * file, int limit); -static int xhtml_do_contents_section_limit(FILE * fp, - xhtmlsection * section, - int limit); -static int xhtml_add_contents_entry(FILE * fp, xhtmlsection * section, - int limit); +static int xhtml_do_contents_section_limit(FILE * fp, xhtmlsection * section, int limit); +static int xhtml_add_contents_entry(FILE * fp, xhtmlsection * section, int limit); static int xhtml_do_contents(FILE * fp, xhtmlfile * file); static int xhtml_do_naked_contents(FILE * fp, xhtmlfile * file); static void xhtml_do_sections(FILE * fp, xhtmlsection * sections); @@ -945,17 +966,39 @@ static void xhtml_do_file(xhtmlfile * file) static void xhtml_do_top_file(xhtmlfile * file, paragraph * sourceform) { paragraph *p; + char fname[_MAX_PATH]; int done = FALSE; FILE *fp = fopen(file->filename, "w"); + ustrtoa(conf.chm_toc_file, fname, _MAX_PATH); + if(*fname) + { + chm_toc = fopen(fname, "w"); + if (chm_toc == NULL) + fatal(err_cantopenw, fname); + } + else + chm_toc = NULL; + + ustrtoa(conf.chm_ind_file, fname, _MAX_PATH); + if(*fname){ + chm_ind = fopen(fname, "w"); + if (chm_ind == NULL) + fatal(err_cantopenw, fname); + } + else + chm_ind = NULL; if (fp == NULL) fatal(err_cantopenw, file->filename); + /* Do the title -- only one allowed */ for (p = sourceform; p && !done; p = p->next) { if (p->type == para_Title) { xhtml_doheader(fp, p->words); + if(chm_toc)chm_doheader(chm_toc, p->words); + if(chm_ind)chm_doheader(chm_ind, p->words); done = TRUE; } } @@ -1008,7 +1051,11 @@ static void xhtml_do_top_file(xhtmlfile * file, paragraph * sourceform) } xhtml_dofooter(fp); + if(chm_toc)chm_dofooter(chm_toc); + if(chm_ind)chm_dofooter(chm_ind); fclose(fp); + if(chm_toc)fclose(chm_toc); + if(chm_ind)fclose(chm_ind); } /* Convert a Unicode string to an ASCII one. '?' is @@ -1053,6 +1100,7 @@ static int xhtml_do_contents(FILE * fp, xhtmlfile * file) { last_level--; fprintf(fp, "\n"); + if(chm_toc)fprintf(chm_toc, "\n"); } } return count; @@ -1077,6 +1125,7 @@ static int xhtml_do_naked_contents(FILE * fp, xhtmlfile * file) { last_level--; fprintf(fp, "\n"); + if(chm_toc)fprintf(chm_toc, "\n"); } } return count; @@ -1125,8 +1174,7 @@ xhtml_do_contents_section_deep_limit(FILE * fp, xhtmlsection * section, * limit contents depth. */ static int -xhtml_do_contents_section_limit(FILE * fp, xhtmlsection * section, - int limit) +xhtml_do_contents_section_limit(FILE * fp, xhtmlsection * section, int limit) { int count = 0; if (!section) @@ -1156,19 +1204,26 @@ xhtml_add_contents_entry(FILE * fp, xhtmlsection * section, int limit) { last_level--; fprintf(fp, "\n"); + if(chm_toc)fprintf(chm_toc, "\n"); } while (last_level < section->level) { last_level++; fprintf(fp, "