From 7c27fbd06853276053b6d06a39d10125fcc7b285 Mon Sep 17 00:00:00 2001 From: Jonas Baumann Date: Thu, 3 Jan 2013 15:57:50 +0100 Subject: [PATCH] rst: use CSS for image alignment. --- lib/github/commands/rest2html | 17 +++++++++++++++++ test/markups/README.rst | 2 ++ test/markups/README.rst.html | 2 ++ 3 files changed, 21 insertions(+) diff --git a/lib/github/commands/rest2html b/lib/github/commands/rest2html index 0efea607..107f2a0b 100755 --- a/lib/github/commands/rest2html +++ b/lib/github/commands/rest2html @@ -207,6 +207,23 @@ class GitHubHTMLTranslator(HTMLTranslator): def depart_table(self, node): self.body.append('\n') + def visit_image(self, node): + """Custom visit_image for using the HTML align attribute for + image alignment, since css-classes will be stripped. + """ + HTMLTranslator.visit_image(self, node) + if self.body[-1].startswith('', ' style="float: %s" />' % align) + def depart_image(self, node): uri = node['uri'] ext = os.path.splitext(uri)[1].lower() diff --git a/test/markups/README.rst b/test/markups/README.rst index 54bd71ce..8488f19d 100644 --- a/test/markups/README.rst +++ b/test/markups/README.rst @@ -76,6 +76,8 @@ someone@somewhere.org Press :kbd:`Ctrl+C` to quit +.. image:: foo.png + :align: right .. raw:: html diff --git a/test/markups/README.rst.html b/test/markups/README.rst.html index 7b8e9fca..cccbb0a8 100644 --- a/test/markups/README.rst.html +++ b/test/markups/README.rst.html @@ -92,4 +92,6 @@

Field list

Press Ctrl+C to quit

+foo.png +

RAW HTML!

p {color:blue;}