bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

permanent links using #fragment names


From: Per Bothner
Subject: permanent links using #fragment names
Date: Sun, 9 Jan 2022 09:32:38 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0

An idea I've been mulling: Currently, we handle changes in node structure
by generating extra stub pages that redirect to the correct location.
This works, but it's a bit clunky.  For one thing, it doesn't update
the location bar (though that could be fixed).  Worse, it highlights a
two-level name hierarchy FILENAME.html#FRAGMENT that depends on
the splitting mode.

Instead, I suggest that the primary and visible name for every node and anchor
use the fragment names (the part after the '#').

For example, the Keys chapter in the Emacs manual would still be in the
file Keys.html, and you can still browse to "https://whatever/emacs/Keys.html";.
However, the "perma-link" would be "https://whatever/emacs#Keys";, and that
is what would show in the location bar.  Currently, 'Keys" is a section,
but the perma-link would remain "emacs#Keys" regardless of whether
it is changed to a chapter or subsection, or of the splitting mode.
Even if the section is renamed, "emacs#Keys" would work as long as
an @anchor with the old name is added.

Implementing this would be trivial in info.js - it already does this
for file: URLs.  That is assuming that info.js can map the fragment
name to the correct file.  Currently, this is done by looking
in the "contents" element in the initial index.html.  To handle
other anchors (not in the contents) I propose texti2any can add them
to the contents as invisible element.  Perhaps:
  <span id="toc-Using-Foo" data-location="Foo.html#Using-Foo" data-toc="subheading" 
data-title="Using Foo"/>

Note this would also help with the issue discussed in the
"control over sectioning and splitting" thread, since info.js
could optionally put subheading (for example) in the side-bar.

An optional-but-nice refinement: When scrolling in a page, update the location 
bar
*and* the side-bar.

Note this doesn't have to be something we force on users: We can still generate
the extra stub files, and we can make it a preference in info.js whether
to prefer the emacs#Keys style in the location bar.

A related change is that we should change how info node/anchor names are
mapped into URLs to use standard %-encoding.  This would make URL cleaner
and more readable.  For continuity, we could map space to '-', '-' to '%45',
and other characters as in standard percent-encoding.  An initial '-' could
be used for texinfo-internal ids such as the "-toc-foo" or "-def-printf".
(I've suggested this before, I'm pretty sure, but I think it makes sense to
co-ordinate these changes, at least for a specific manual.)
--
        --Per Bothner
per@bothner.com   http://per.bothner.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]