Hi,
In version 0.6.1 sphinx/writers/html.py HTMLTranslator.depart_title does
not take into account the situation where a title is a backref-link to
toc and has also a permalink, i.e. the text of h-tag consists of two
separate links.
Therefore Sphinx's html-builder produces nested a-tags (not valid XHTML):
<h2><a class="toc-backref" href="#id4">Title<a class="headerlink"
href="#what" title="Permalink to this headline">¶</a></a></h2>
when the correct production would obviously be:
<h2><a class="toc-backref" href="#id4">Title</a><a class="headerlink"
href="#what" title="Permalink to this headline">¶</a></h2>
I'm quite new to Sphinx and I'm not sure if there is something else I
should take into account, but I made my patch-proposal. I tried to
change as little as possible.
See permalink-backref.patch included as an attachment.
--
Tuomas `tuos` Räsänen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---
--- sphinx/writers/html.py~ 2009-03-24 20:51:15.000000000 +0000
+++ sphinx/writers/html.py 2009-04-19 12:55:19.000000000 +0000
@@ -463,15 +463,19 @@
def depart_title(self, node):
close_tag = self.context[-1]
- if self.add_permalinks and self.builder.add_permalinks and \
- (close_tag.startswith('</h') or
- close_tag.startswith('</a></h')) and \
- node.parent.hasattr('ids') and node.parent['ids']:
+ if (self.add_permalinks and self.builder.add_permalinks and
+ node.parent.hasattr('ids') and node.parent['ids']):
aname = node.parent['ids'][0]
# add permalink anchor
- self.body.append(u'<a class="headerlink" href="#%s" ' % aname +
- u'title="%s">\u00B6</a>' %
- _('Permalink to this headline'))
+ if close_tag.startswith('</h'):
+ self.body.append(u'<a class="headerlink" href="#%s" ' % aname +
+ u'title="%s">\u00B6</a>' %
+ _('Permalink to this headline'))
+ elif close_tag.startswith('</a></h'):
+ self.body.append(u'</a><a class="headerlink" href="#%s" ' % aname +
+ u'title="%s">\u00B6' %
+ _('Permalink to this headline'))
+
BaseTranslator.depart_title(self, node)
def unknown_visit(self, node):