Skip to content

Commit 6b0f5bc

Browse files
committed
Merge pull request #287 from github/fix-rst-dotdot
Swap RST's use of `object` for SVG to use `image`
2 parents ba710cb + 7a9da18 commit 6b0f5bc

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

lib/github/commands/foo.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
.. image:: https://scan.coverity.com/projects/621/badge.svg
3+
:target: https://scan.coverity.com/projects/621
4+
:alt: Coverity Scan Build Status
5+
6+
.. image:: https://scan.coverity.com/projects/621/badge.svg
7+
:alt: Coverity Scan Build Status

lib/github/commands/rest2html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ __license__ = "CC0"
2828
__version__ = "0.1"
2929

3030
import sys
31+
import os
3132

3233
# This fixes docutils failing with unicode parameters to CSV-Table. The -S
3334
# switch and the following 2 lines can be removed after upgrading to python 3.
@@ -89,6 +90,28 @@ class GitHubHTMLTranslator(HTMLTranslator):
8990
def depart_table(self, node):
9091
self.body.append('</table>\n')
9192

93+
def depart_image(self, node):
94+
uri = node['uri']
95+
ext = os.path.splitext(uri)[1].lower()
96+
# we need to swap RST's use of `object` with `img` tags
97+
# see http://git.io/5me3dA
98+
if ext == ".svg":
99+
# preserve essential attributes
100+
atts = {}
101+
for attribute, value in node.attributes.items():
102+
# we have no time for empty values
103+
if value:
104+
if attribute == "uri":
105+
atts['src'] = value
106+
else:
107+
atts[attribute] = value
108+
109+
# toss off `object` tag
110+
self.body.pop()
111+
# add on `img` with attributes
112+
self.body.append(self.starttag(node, 'img', **atts))
113+
self.body.append(self.context.pop())
114+
92115
def main():
93116
"""
94117
Parses the given ReST file or the redirected string input and returns the

test/markups/README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ API http://pullv.readthedocs.org/en/latest/api.html
3333
Issues https://github.com/tony/pullv/issues
3434
Source https://github.com/tony/pullv
3535
============== ==========================================================
36+
37+
38+
.. image:: https://scan.coverity.com/projects/621/badge.svg
39+
:target: https://scan.coverity.com/projects/621
40+
:alt: Coverity Scan Build Status
41+
42+
.. image:: https://scan.coverity.com/projects/621/badge.svg
43+
:alt: Coverity Scan Build Status

test/markups/README.rst.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ <h2>Header 2</h2>
4949
</tr>
5050
</tbody>
5151
</table>
52+
<a class="reference external image-reference" href="https://scan.coverity.com/projects/621"><img alt="Coverity Scan Build Status" src="https://scan.coverity.com/projects/621/badge.svg">
53+
</a>
54+
<img alt="Coverity Scan Build Status" src="https://scan.coverity.com/projects/621/badge.svg">

0 commit comments

Comments
 (0)