summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2020-04-03 16:57:47 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2020-04-03 16:57:47 +0000
commitb60b7c428ec84b2252cb2d4f49883d3f217f7c19 (patch)
treec32fc3eae3266030adb850b3178e96b9f1269ee6 /docutils
parent7a21ddf601e29a25e492ba97309d593e6eeff6b4 (diff)
downloaddocutils-b60b7c428ec84b2252cb2d4f49883d3f217f7c19.tar.gz
html5 writer: classify image references also for inline images.
Add "inmage-reference" to the class arguments for all references that contain only one image node. Allows CSS styling to underline text links but not image links. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8511 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
-rw-r--r--docutils/docutils/writers/_html_base.py3
-rw-r--r--docutils/test/functional/expected/standalone_rst_html5.html2
2 files changed, 3 insertions, 2 deletions
diff --git a/docutils/docutils/writers/_html_base.py b/docutils/docutils/writers/_html_base.py
index 6fd2d91c8..bda323050 100644
--- a/docutils/docutils/writers/_html_base.py
+++ b/docutils/docutils/writers/_html_base.py
@@ -1323,11 +1323,12 @@ class HTMLTranslator(nodes.NodeVisitor):
'References must have "refuri" or "refid" attribute.'
atts['href'] = '#' + node['refid']
atts['class'] += ' internal'
+ if len(node) == 1 and isinstance(node[0], nodes.image):
+ atts['class'] += ' image-reference'
if not isinstance(node.parent, nodes.TextElement):
assert len(node) == 1 and isinstance(node[0], nodes.image)
if not isinstance(node.parent, (nodes.figure, nodes.compound)):
self.body.append('<p class="image-wrapper">')
- atts['class'] += ' image-reference'
self.body.append(self.starttag(node, 'a', '', **atts))
def depart_reference(self, node):
diff --git a/docutils/test/functional/expected/standalone_rst_html5.html b/docutils/test/functional/expected/standalone_rst_html5.html
index 3906cd610..9b8efb6df 100644
--- a/docutils/test/functional/expected/standalone_rst_html5.html
+++ b/docutils/test/functional/expected/standalone_rst_html5.html
@@ -1833,7 +1833,7 @@ section, &quot;Docutils System Messages&quot;:</p>
</main>
<footer>
<p>Document footer</p>
-<p><a class="reference external" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" style="width: 88px; height: 31px;" /></a> <a class="reference external" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" style="width: 88px; height: 31px;" /></a> <a class="reference external" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p>
+<p><a class="reference external image-reference" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" style="width: 88px; height: 31px;" /></a> <a class="reference external image-reference" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p>
</footer>
</body>