As a user of Alectryon (a tool relying on docutils to generate webpages from literate-programming code), I had submitted that issue / feature request: https://github.com/cpitclaudel/alectryon/issues/19 (Make anchors visible in Alectryon's webpage output).
And the author suggested that the availability of this feature directly relies on docutils:
That's a great idea. I think it would require a change to Docutils html writer, specifically the
visit_title
function inwriters/_html_base.py
. Could you open a feature request on the docutils tracker?
Hence this ticket :) So do you confirm this feature is lacking in docutils?
Because on second thought (after reading https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/docutils/writers/_html_base.py#l37), I believe the code below should already do the job?
self.body.append( self.starttag(node, 'h%s' % h_level, '', **atts)) atts = {} if node.hasattr('refid'): atts['class'] = 'toc-backref' atts['href'] = '#' + node['refid'] if atts: self.body.append(self.starttag({}, 'a', '', **atts)) close_tag = '</a></h%s>\n' % (h_level) else: close_tag = '</h%s>\n' % (h_level)
Thanks in advance for your reply and help
Sorry I realize I clicked on Submit too early (before putting a complete title to the ticket 😅)
Last edit: Erik Martin-Dorel 2021-03-11
i would prefer additional
reStructured input
xxxx
current output
xxxx
desired output
xxxx
dont i
Last edit: engelbert gruber 2021-03-13
Here you go:
reStructured input
current output
desired output
This depends on what you really want:
A user can easily click on the backlink and copy/bookmark the ToC entry linking to the section.
Indeed this is the intended feature :-)
Regarding the implementation itself − a symbol such as ¶ after the section title (like Clément proposed) or just before − I've no strong opinion.
Thanks for your remark! Indeed that can be solution :-)
But as these links will only be generated if there is a ToC, do you think it would be useful to add an independent feature similar to that of Sphinx, or to GitHub's rendering of Markdown files? − https://user-images.githubusercontent.com/10367254/107887926-e1e1ea00-6f09-11eb-8b48-ccdb4b3f4452.png so that even if the ToC is not enabled, users would have by default (but may disable) a small symbol such as ¶…
What do you think?
Duplicate of https://sourceforge.net/p/docutils/feature-requests/28/