-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
HTML5 permalinks are not permanent if section header starts with number #8709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The reason to the current behaviour is likely due to the HTML4 spec:
So The behaviour still feels quite unintuitive to me, however. I would expect Sphinx to generate something more stable, such as With that said, you can always specify an explicit reference yourself:
This would always work regardless of the section title. |
Sphinx generates HTML5 by default since 2.0 #4587 |
It comes from the node ID generation rule of docutils; the core library of Sphinx. It was defined to support many kinds of formats. |
What is the role of this function then? Lines 435 to 439 in 3ed7590
|
It's a local ID generator for Sphinx domains. It does not relate to the section IDs. |
It looks like an override by import path. Although it doesn't make it any better.
Is it possible to define a function |
The same behavior also goes with non-ASCII headers, producing |
@madjxatw understood. HTML5 removes all restrictions from IDs, which makes even these valid.
|
@abitrolly, exactly, so Sphinx needs to implement a HTML5 version of |
@madjxatw not Sphinx, some human needs to sit down and write the code. While the code seems trivial, right now it is unclear where to place the code. |
@abitrolly, hopefully some unicode slugifier (e.g. https://github.com/mozilla/unicode-slugify) could be used as an extension or be integrated somehow into Sphinx. |
Sphinx has still supported HTML4 output. The HTML Help builder also depends on HTML4. In addition to this, I can't say the change does not affect other builders. Sphinx is not only for building HTML5. |
@tk0miya, is it possible to have an option that lets users decide whether to enable unicode permalink? |
I can't promise the option works fine for "all" builders. If I added it to Sphinx, I'll describe it as "it might work. But not promised. Please don't report us even if something broken" :-p |
That's all right, it wouldn't be a big problem to hack it by ourselves , however it still sounds a bit sorry that unicode IDs is not officially supported, especially for those non-English (e.g. East Asian) writers who really need IDs with their own language characters. :-( |
I don't know about the details about how Sphinx works internally, but couldn't a custom unicode ID maker be invoked only when the HTML5 builder is in use? |
It's diffucult. The node IDs are generated in the reading phase. The result of the phase is cached and used for incremental builds. It means introducing the new ID breaks the incremental build feature. |
But HTML IDs should not be node IDs. Is it possible during initial read to generate IDs in a structure that allows to output a proper HTML5 slug on writing? Like if ID is autogenerated from the title, store the title. |
Of course, it's possible if you give a wonderful patch! (IMO, it's impossible to me as I commented "it's difficult" above). |
@tk0miya what do you mean by |
The cross-referencing system of Sphinx has been based on the node IDs. So I can't imagine how we replace it by unicode IDs. I guess we need to rewrite whole of docutils and Sphinx. So I can't tell you where to do that. |
@tk0miya the idea is not about replacing internal node IDs. It is about writing IDs in HTML5 format on output to HTML5. All IDs written this way will be consistent. |
I don't know how to do that. But all contributions are welcome! |
I am afraid I can go on only with funded contributions. Learning a codebase like this in my free time is not sustainable. A pity that this seemingly simple generator turned out to be that complex on the inside. |
|
In
pip
Changelog
slugs in html anchors are not permanently pointed to corresponding version. Instead, they are incremental position numbers, which start with#id1
, so when new version ofpip
is released all anchors shift and start to point to a different version.To Reproduce
This gives the output.
Expected behavior
Environment info
Additional context
The text was updated successfully, but these errors were encountered: