Fix #1788: graphviz extension raises exception when caption option is present

This commit is contained in:
shimizukawa 2015-03-21 11:53:24 +09:00
parent 1c32a0fc3e
commit 11f9b5ff20
2 changed files with 5 additions and 2 deletions

View File

@ -4,6 +4,8 @@ Release 1.3.2 (in development)
Bugs fixed
----------
* #1788: graphviz extension raises exception when caption option is present.
Release 1.3.1 (released Mar 17, 2015)
=====================================

View File

@ -349,8 +349,9 @@ class HTMLTranslator(BaseTranslator):
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
self.add_permalink_ref(node.parent, _('Permalink to this code'))
elif isinstance(node.parent, nodes.figure):
self.add_permalink_ref(
node.parent.traverse(nodes.image)[0], _('Permalink to this image'))
image_nodes = node.parent.traverse(nodes.image)
target_node = image_nodes and image_nodes[0] or node.parent
self.add_permalink_ref(target_node, _('Permalink to this image'))
elif node.parent.get('toctree'):
self.add_permalink_ref(node.parent.parent, _('Permalink to this toctree'))