From 2dcd218d343644f65b34bf6075267c630a228cc7 Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 31 Jan 2007 23:32:12 +0000 Subject: [PATCH] Add an `Up' link to the HTML navigation bar of sufficiently deep documents. (This doesn't affect any of the source texts I know about.) Also add , even in the cases where it's just the same as . (This does.) git-svn-id: svn://svn.tartarus.org/sgt/halibut@7193 cda61777-01e9-0310-a592-d414129be87e --- bk_html.c | 34 +++++++++++++++++++++++++++++++--- doc/index.but | 3 +++ doc/output.but | 7 +++++-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/bk_html.c b/bk_html.c index 1d4aa5b..0c66eb7 100644 --- a/bk_html.c +++ b/bk_html.c @@ -61,7 +61,7 @@ typedef struct { char *body_tag, *nav_attr; wchar_t *author, *description; wchar_t *index_text, *contents_text, *preamble_text, *title_separator; - wchar_t *nav_prev_text, *nav_next_text, *nav_separator; + wchar_t *nav_prev_text, *nav_next_text, *nav_up_text, *nav_separator; wchar_t *index_main_sep, *index_multi_sep; wchar_t *pre_versionid, *post_versionid; int restrict_charset, output_charset; @@ -282,6 +282,7 @@ static htmlconfig html_configure(paragraph *source) { ret.title_separator = L" - "; ret.nav_prev_text = L"Previous"; ret.nav_next_text = L"Next"; + ret.nav_up_text = L"Up"; ret.nav_separator = L" | "; ret.index_main_sep = L": "; ret.index_multi_sep = L", "; @@ -494,6 +495,8 @@ static htmlconfig html_configure(paragraph *source) { ret.nav_prev_text = uadv(k); } else if (!ustricmp(k, L"html-nav-next-text")) { ret.nav_next_text = uadv(k); + } else if (!ustricmp(k, L"html-nav-up-text")) { + ret.nav_up_text = uadv(k); } else if (!ustricmp(k, L"html-nav-separator")) { ret.nav_separator = uadv(k); } else if (!ustricmp(k, L"html-index-main-separator")) { @@ -970,8 +973,6 @@ void html_backend(paragraph *sourceform, keywordlist *keywords, html_nl(&ho); } - /* FIXME: link rel="up" */ - if (f != files.head) { element_empty(&ho, "link"); element_attr(&ho, "rel", "ToC"); @@ -979,6 +980,17 @@ void html_backend(paragraph *sourceform, keywordlist *keywords, html_nl(&ho); } + if (conf.leaf_level > 0) { + htmlsect *p = f->first->parent; + assert(p == f->last->parent); + if (p) { + element_empty(&ho, "link"); + element_attr(&ho, "rel", "up"); + element_attr(&ho, "href", p->file->filename); + html_nl(&ho); + } + } + if (has_index && files.index && f != files.index) { element_empty(&ho, "link"); element_attr(&ho, "rel", "index"); @@ -1057,6 +1069,22 @@ void html_backend(paragraph *sourceform, keywordlist *keywords, if (f != files.head) element_close(&ho, "a"); + /* We don't bother with "Up" links for leaf-level 1, + * as they would be identical to the "Contents" links. */ + if (conf.leaf_level >= 2) { + htmlsect *p = f->first->parent; + assert(p == f->last->parent); + html_text(&ho, conf.nav_separator); + if (p) { + element_open(&ho, "a"); + element_attr(&ho, "href", p->file->filename); + } + html_text(&ho, conf.nav_up_text); + if (p) { + element_close(&ho, "a"); + } + } + if (has_index && files.index) { html_text(&ho, conf.nav_separator); if (f != files.index) { diff --git a/doc/index.but b/doc/index.but index e9d6e51..351e3d2 100644 --- a/doc/index.but +++ b/doc/index.but @@ -305,6 +305,9 @@ configuration directive \IM{\\cfg\{html-nav-next-text\}} \c{html-nav-next-text} configuration directive \IM{\\cfg\{html-nav-next-text\}} \cw{\\cfg\{html-nav-next-text\}} +\IM{\\cfg\{html-nav-up-text\}} \c{html-nav-up-text} configuration directive +\IM{\\cfg\{html-nav-up-text\}} \cw{\\cfg\{html-nav-up-text\}} + \IM{\\cfg\{html-nav-separator\}} \c{html-nav-separator} configuration directive \IM{\\cfg\{html-nav-separator\}} \cw{\\cfg\{html-nav-separator\}} diff --git a/doc/output.but b/doc/output.but index 0cea3c2..98637df 100644 --- a/doc/output.but +++ b/doc/output.but @@ -664,8 +664,10 @@ the index. \dt \I{\cw{\\cfg\{html-nav-next-text\}}}\cw{\\cfg\{html-nav-next-text\}\{}\e{text}\cw{\}} -\dd The text used for the \q{previous page} and \q{next page} links on -the navigation bar. +\dt \I{\cw{\\cfg\{html-nav-up-text\}}}\cw{\\cfg\{html-nav-up-text\}\{}\e{text}\cw{\}} + +\dd The text used for the \q{previous page}, \q{next page}, and \q{up} +links on the navigation bar. \dt \I{\cw{\\cfg\{html-nav-separator\}}}\cw{\\cfg\{html-nav-separator\}\{}\e{text}\cw{\}} @@ -965,6 +967,7 @@ The \i{default settings} for Halibut's HTML output format are: \c \cfg{html-post-versionid}{]} \c \cfg{html-nav-prev-text}{Previous} \c \cfg{html-nav-next-text}{Next} +\c \cfg{html-nav-up-text}{Up} \c \cfg{html-nav-separator}{ | } \c \c \cfg{html-output-charset}{ASCII} -- 2.11.0