From b60b7c428ec84b2252cb2d4f49883d3f217f7c19 Mon Sep 17 00:00:00 2001 From: milde Date: Fri, 3 Apr 2020 16:57:47 +0000 Subject: 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 --- docutils/docutils/writers/_html_base.py | 3 ++- docutils/test/functional/expected/standalone_rst_html5.html | 2 +- 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('

') - 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, "Docutils System Messages":

-- cgit v1.2.1