diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py
index b03a64120..15f841517 100644
--- a/sphinx/builders/html.py
+++ b/sphinx/builders/html.py
@@ -12,9 +12,11 @@
import os
import codecs
import shutil
+import posixpath
import cPickle as pickle
from os import path
+from docutils import nodes
from docutils.io import DocTreeInput, StringOutput
from docutils.core import publish_parts
from docutils.utils import new_document
@@ -253,11 +255,11 @@ class StandaloneHTMLBuilder(Builder):
)
def write_doc(self, docname, doctree):
- self.post_process_images(doctree)
destination = StringOutput(encoding='utf-8')
doctree.settings = self.docsettings
self.imgpath = relative_uri(self.get_target_uri(docname), '_images')
+ self.post_process_images(doctree)
self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads')
self.docwriter.write(doctree, destination)
self.docwriter.assemble_parts()
@@ -486,6 +488,29 @@ class StandaloneHTMLBuilder(Builder):
# clean up theme stuff
self.theme.cleanup()
+ def post_process_images(self, doctree):
+ """
+ Pick the best candiate for an image and link down-scaled images to
+ their high res version.
+ """
+ Builder.post_process_images(self, doctree)
+ for node in doctree.traverse(nodes.image):
+ if not node.has_key('scale') or \
+ isinstance(node.parent, nodes.reference):
+ # docutils does unfortunately not preserve the
+ # ``target`` attribute on images, so we need to check
+ # the parent node here.
+ continue
+ uri = node['uri']
+ reference = nodes.reference()
+ if uri in self.images:
+ reference['refuri'] = posixpath.join(self.imgpath,
+ self.images[uri])
+ else:
+ reference['refuri'] = uri
+ node.replace_self(reference)
+ reference.append(node)
+
def get_outdated_docs(self):
if self.templates:
template_mtime = self.templates.newest_template_mtime()
diff --git a/sphinx/themes/basic/static/basic.css b/sphinx/themes/basic/static/basic.css
index 5a27fc165..ed737d3ba 100644
--- a/sphinx/themes/basic/static/basic.css
+++ b/sphinx/themes/basic/static/basic.css
@@ -82,7 +82,7 @@ div.sphinxsidebar input {
font-size: 1em;
}
-img.logo {
+img {
border: 0;
}