-
Notifications
You must be signed in to change notification settings - Fork 18
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
[#60] Fix html anchors #61
Conversation
For the very first rst file toc entry, Sphinx doesn't add an anchor, but instead uses file's title. Because of that, some links in Table of contents of PDF document are not correct, resulting in wrong page numbers. Fix replaces all such anchors with the correct ones, after the creation of HTML document.
Thanks for the PR. 👍 Can you mention the fix in docs/changelog.rst? |
Currently i ran into problems with this fix due to Chapters/Sections containing ReST substitutions.
Will lead to ids "doc-type-name-project", but the "parsing" of the index html leads to "substituted" text. E.g. link to "Help TrafficLight" if doc_type_name is substitued by "Help" etc. I think the linking is no problem, the problem is that the id generated and refered is the id of a span element and the heading is on a new page due to the page-break-before css property in sphinx-simplepdf main.css So using substitutions in headers should be usable cause they are a sphinx feature and the toctree fix should not be applied, maybe the css should be improved. |
The toctree fix also breaks documents / ReST files with "sections" not made in pure ReST, e.g if the section comes from "custom directives". E.g. in a test procedure document, i add sections via my own directives. The document itself has no title / section in ReST. So the first title tocfix does generate a an invalid link |
During investigation of this issue i found it somewhere difficult to handle properly the page-breaks for h1/h2 for all purposes (cover yes/no, sidebar yes/no) for the first occuring headings of this levels in the body. Therefore i would suggest to enumerate them to handle the page-breaks properly in the css.
This would ensure to properly identify the headings in css and handle the prage-breaks properly As an example my custom css for page page handling
css selectors like Maybe the handling could implemented in an other ways (class instead of id, stop enumeration after first element etc). |
Can you create a new issue for this? I'm not sure if I like the idea of enumerating the headings, as it is not a fixed, reproducible ID. But I don't have a good idea for a different solution. |
For the very first rst file toc entry, Sphinx doesn't add an anchor, but instead uses file's title.
Because of that, some links in Table of contents of PDF document are not correct, resulting in wrong page numbers.
Fix replaces all such anchors with the correct ones, after the creation of HTML document.