Add autopermalink toggle feature for HTML rendering#2816
Add autopermalink toggle feature for HTML rendering#2816blrichwine wants to merge 4 commits intoPreTeXtBook:masterfrom
Conversation
|
Note: I have a sample implementation of the feature in the examples/minimal book hosted here: https://brichwin.pages.iu.edu/min/minimal.html |
|
Thanks, @brichwin. I would be annoyed stopping and hearing all those permalinks! So it would be good to have more control over them. We have been talking about a general user preferences/readability menu (and had a trial one once a while back). Maybe this can help move that forward. Feels like that is where it belongs. |
|
Some thoughts when first seeing this idea:
1) The default should be that permalinks are there. I can explain my
reasoning, but please think about it.
2) Having the "enable/disable" link in the navbar is not really
that helpful to a reader who cannot see, or who has to use the
keyboard to navigate there.
3) A non-sighted/keyboard navigating reader is probably going to
use the "skip to main content" link. Perhaps following that link
turns off the permalinks?
4) This would be a great addition to a user preferences menu,
but maybe this is worth implementing now, and then later it moves
into the preferences menu (which will occupy the space where this
is temporarily located).
…On Thu, 2 Apr 2026, Rob Beezer wrote:
[1881714?s=20&v=4] rbeezer left a comment (PreTeXtBook/pretext#2816)
Thanks, @brichwin. I would be annoyed stopping and hearing all those permalinks! So it would be good to have more control over them.
We have been talking about a general user preferences/readability menu (and had a trial one once a while back). Maybe this can help move that forward.
Feels like that is where it belongs.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to thisthread.[AABTULCA6YJSXDZUBC5GO7T4T36MTBFCNFSM6AAAAACXLGBHRWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTXZGZZU5JTSMVQXG33OVJZXKYTTMNZGSY
TFMQ.gif] Message ID: ***@***.***>
|
The student screen-reader users I've worked with don't use the skip to content links on sites. They mainly use headings to get to the main content by pressing the 'H' quick nav key till they get there. Also, you really don't want simple navigation of a site to change user settings. It wouldn't be very transparent. And they might actually want to use the permalink feature. We have several instructors that use screen-readers... |
Description
This PR adds a proof-of-concept toggle feature that allows readers to show and hide
div.autopermalinkelements in HTML output of a PreTeXt textbook.Note: I attended the Zoom PreTeXt Dropin on Thursday 2026-04-02 and discussed the autopermalink toggle. Oscar and Chrissy mentioned I should create a PR so they can see the sample implementation and be reminded to consider the feature request. It was mentioned that the actual feature if implemented would likely be implemented differently and I am totally fine with that.
Motivation
Permalink icons are always presented to screen-reader users in the current output. We received feedback from screen reader users evaluating our use of PreTeXt. They reported that repeatedly hearing "Link: Copy heading and permalink for Paragraph" while reading a textbook is both distracting and annoying. These links also present numerous tab stops to keyboard only users that may not be interested in creating permalinks.
The fix we propose is to have permalinks links enabled only when needed, then the best of both worlds can be achieved.
Enabling the Feature
For this proof-of-concept, the feature is enabled on a per book basis. In the publisher file, add
<permalink-button/>inside an<html>element:Behavior
div.autopermalinkelements are hidden by default on page loadlink)— clicking will show permalinkslink_off) — clicking will hide permalinksAccessibility
aria-labelattribute that updates to describe the action the button will perform, consistent with the pattern used by other PreTeXt navbar controlsdisplay: noneremoves hidden permalinks from both the visual and accessibility treeOther notes
en-US.xml. Other locales have not been provided. These will fallback to English automatically until translators add their own entries.ptx_default_settingsJS object is how this code is passing the XSL settings to the new JS. Isptx_default_settingsthe right pattern for passing XSL settings to the JS space, or is there a preferred alternative?aria-pressedattribute on the button, but feedback from a JAWS screen reader was that having both the changing button name and the aria-pressed state was confusing. Thearia-pressedattribute was removed the JAWS user reported this was best.Description of changes
xsl/publisher-variables.xsl:$b-has-permalink-buttonvariable reading$publication/html/permalink-buttonxsl/pretext-html.xsl:permalink-toggle-buttonnamed templateprimary-navigation-other-controlsptx_default_settingsscript blockxsl/localizations/en-US.xmlpermalink-enableandpermalink-disablelocalization string IDsjs/pretext_add_on.jsinitPermalinkToggle()andsetPermalinkVisibility()data-attributes