[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [help-texinfo] <title> in multi-node HTML
From: |
Gavin Smith |
Subject: |
Re: [help-texinfo] <title> in multi-node HTML |
Date: |
Mon, 31 Dec 2018 23:49:13 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Sun, Nov 11, 2018 at 06:41:02PM +0100, Akim Demaille wrote:
> The HTML reads:
>
> <title>Understanding (Bison 3.2.1)</title>
>
> Is there a means to use the section name rather that the node name in the
> generated HTML? It???s quite common to have a very short node name, but a
> fully blown section name, so the latter seems more appropriate to me.
>
> Even in Texinfo???s own documentation, you have for instance the title « One
> argument », which hardly makes sense alone:
>
> https://www.gnu.org/software/texinfo/manual/texinfo/html_node/One-Argument.html
>
> but the page is
>
> 6.4.1 @xref with One Argument
I don't see why there couldn't be an option to use the name of the
chapter, section or sub-section as the HTML <title>. The title isn't
seen very much in any case: in window title bars, on browser tabs and in
search engine results. My feeling is that the default should remain
as the node name given as the argument to @node. It's the safer option
to keep things as they are.
Here's code to add an option SECTION_NAME_IN_TITLE, used by passing
"-c SECTION_NAME_IN_TITLE=1" to texi2any. Any comments on this?
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index c406554..336345d 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -222,7 +222,8 @@ my @variable_string_settables = (
'ENABLE_ENCODING_USE_ENTITY', 'ICONS',
'USE_UNIDECODE', 'DATE_IN_HEADER', 'OPEN_QUOTE_SYMBOL',
'CLOSE_QUOTE_SYMBOL', 'TOP_NODE_UP', 'TOP_NODE_UP_URL', 'TOP_NODE_FILE',
- 'TOP_NODE_FILE_TARGET', 'SHOW_TITLE', 'WORDS_IN_PAGE',
+ 'TOP_NODE_FILE_TARGET', 'SECTION_NAME_IN_TITLE',
+ 'SHOW_TITLE', 'WORDS_IN_PAGE',
'HEADER_IN_TABLE', 'USE_ACCESSKEY', 'USE_REL_REV', 'USE_LINKS',
'OVERVIEW_LINK_TO_TOC', 'AVOID_MENU_REDUNDANCY', 'NODE_NAME_IN_MENU',
'NODE_NAME_IN_INDEX', 'NO_USE_SETFILENAME', 'USE_SETFILENAME_EXTENSION',
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 654257e..10d3073 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -1007,6 +1007,7 @@ my %defaults = (
'documentlanguage' => 'en',
'xrefautomaticsectiontitle' => 'off',
'SHOW_TITLE' => 1,
+ 'SECTION_NAME_IN_TITLE' => 0,
'USE_TITLEPAGE_FOR_TITLE' => 0,
'MONOLITHIC' => 1,
'CHAPTER_HEADER_LEVEL' => 2,
@@ -6225,7 +6226,8 @@ $pre_body_close
}
# This is used for normal output files and other files, like renamed
-# nodes file headers, or redirection file headers.
+# nodes file headers, or redirection file headers. $COMMAND is the tree
+# element for a @node that is being output in the file.
sub _file_header_informations($$)
{
my $self = shift;
@@ -6239,9 +6241,20 @@ sub _file_header_informations($$)
and $command_string ne $self->{'title_string'}) {
print STDERR "DO <title>\n"
if ($self->get_conf('DEBUG'));
+
+ my $element_tree;
+ if ($self->get_conf('SECTION_NAME_IN_TITLE')
+ and $command->{'extra'}
+ and $command->{'extra'}->{'associated_section'}
+ and $command->{'extra'}->{'associated_section'}->{'args'}
+ and $command->{'extra'}->{'associated_section'}->{'args'}->[0]) {
+ $element_tree =
$command->{'extra'}->{'associated_section'}->{'args'}->[0];
+ } else {
+ $element_tree = $self->command_text($command, 'tree');
+ }
my $title_tree = $self->gdt('{element_text} ({title})',
{ 'title' => $self->{'title_tree'},
- 'element_text' => $self->command_text($command, 'tree')});
+ 'element_text' => $element_tree });
$title = $self->convert_tree_new_formatting_context(
{'type' => '_string', 'contents' => [$title_tree]},
$command->{'cmdname'}, 'element_title');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [help-texinfo] <title> in multi-node HTML,
Gavin Smith <=