Re: [help-texinfo] in multi-node HTML</span></a></span> </h1> <p class="darkgray font13"> <span class="sender pipe"><a href="/search?l=bug-texinfo@gnu.org&q=from:%22Gavin+Smith%22" rel="nofollow"><span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Gavin Smith</span></span></a></span> <span class="date"><a href="/search?l=bug-texinfo@gnu.org&q=date:20181231" rel="nofollow">Mon, 31 Dec 2018 15:48:11 -0800</a></span> </p> </div> <div itemprop="articleBody" class="msgBody"> <!--X-Body-of-Message--> <pre>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: > > <a rel="nofollow" href="https://www.gnu.org/software/texinfo/manual/texinfo/html_node/One-Argument.html">https://www.gnu.org/software/texinfo/manual/texinfo/html_node/One-Argument.html</a> > > but the page is > > 6.4.1 @xref with One Argument</pre><pre> 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'); </pre> </div> <div class="msgButtons margintopdouble"> <ul class="overflow"> <li class="msgButtonItems"><a class="button buttonleft " accesskey="p" href="msg08929.html">Previous message</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="c" href="index.html#08931">View by thread</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="i" href="maillist.html#08931">View by date</a></li> <li class="msgButtonItems textalignright"><a class="button buttonright " accesskey="n" href="msg08984.html">Next message</a></li> </ul> </div> <a name="tslice"></a> <div class="tSliceList margintopdouble"> <ul class="icons monospace"> <li class="icons-email tSliceCur"><span class="subject">Re: [help-texinfo] <title> in multi-node HTML</span> <span class="sender italic">Gavin Smith</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg08984.html">Re: [help-texinfo] <title> in multi-node HTML</a></span> <span class="sender italic">Akim Demaille</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg08985.html">(offtopic) perl verbosity</a></span> <span class="sender italic">Gavin Smith</span></li> </ul> </ul> </ul> </div> <div class="overflow msgActions margintopdouble"> <div class="msgReply" > <h2> Reply via email to </h2> <form method="POST" action="/mailto.php"> <input type="hidden" name="subject" value="Re: [help-texinfo] <title> in multi-node HTML"> <input type="hidden" name="msgid" value="20181231234913.GA16690@darkstar.lan"> <input type="hidden" name="relpath" value="bug-texinfo@gnu.org/msg08931.html"> <input type="submit" value=" Gavin Smith "> </form> </div> </div> </div> <div class="aside" role="complementary"> <div class="logo"> <a href="/"><img src="/logo.png" width=247 height=88 alt="The Mail Archive"></a> </div> <form class="overflow" action="/search" method="get"> <input type="hidden" name="l" value="bug-texinfo@gnu.org"> <label class="hidden" for="q">Search the site</label> <input class="submittext" type="text" id="q" name="q" placeholder="Search bug-texinfo"> <input class="submitbutton" name="submit" type="image" src="/submit.png" alt="Submit"> </form> <div class="nav margintop" id="nav" role="navigation"> <ul class="icons font16"> <li class="icons-home"><a href="/">The Mail Archive home</a></li> <li class="icons-list"><a href="/bug-texinfo@gnu.org/">bug-texinfo - all messages</a></li> <li class="icons-about"><a href="/bug-texinfo@gnu.org/info.html">bug-texinfo - about the list</a></li> <li class="icons-expand"><a href="/search?l=bug-texinfo@gnu.org&q=subject:%22Re%5C%3A+%5C%5Bhelp%5C-texinfo%5C%5D+%3Ctitle%3E+in+multi%5C-node+HTML%22&o=newest&f=1" title="e" id="e">Expand</a></li> <li class="icons-prev"><a href="msg08929.html" title="p">Previous message</a></li> <li class="icons-next"><a href="msg08984.html" title="n">Next message</a></li> </ul> </div> <div class="listlogo margintopdouble"> </div> <div class="margintopdouble"> </div> </div> </div> <div class="footer" role="contentinfo"> <ul> <li><a href="/">The Mail Archive home</a></li> <li><a href="/faq.html#newlist">Add your mailing list</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/faq.html#support">Support</a></li> <li><a href="/faq.html#privacy">Privacy</a></li> <li class="darkgray">20181231234913.GA16690@darkstar.lan</li> </ul> </div> </body> </html> <script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'9d6816400f64c78f',t:'MTc3MjUzNTA5Ng=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script>