diff options
-rw-r--r-- | sphinx/htmlwriter.py | 8 | ||||
-rw-r--r-- | tests/path.py | 19 | ||||
-rw-r--r-- | tests/root/markup.txt | 5 | ||||
-rw-r--r-- | tests/test_build.py | 1 |
4 files changed, 12 insertions, 21 deletions
diff --git a/sphinx/htmlwriter.py b/sphinx/htmlwriter.py index b4d700cc6..48b993954 100644 --- a/sphinx/htmlwriter.py +++ b/sphinx/htmlwriter.py @@ -194,9 +194,11 @@ class HTMLTranslator(BaseTranslator): if node.has_key('linenos'): linenos = node['linenos'] highlighted = self.highlighter.highlight_block(node.rawsource, lang, linenos) - starttag = self.starttag(node, 'div', suffix='')[:-1] - self.body.append(starttag + highlighted[4:]) # skip '<div' and replace by - # one possibly containing id attr + starttag = self.starttag(node, 'div', suffix='') + if starttag != '<div>': + self.body.append(starttag + highlighted + '</div>\n') + else: + self.body.append(highlighted) raise nodes.SkipNode def visit_doctest_block(self, node): diff --git a/tests/path.py b/tests/path.py index 5ce1d1181..ceb895f50 100644 --- a/tests/path.py +++ b/tests/path.py @@ -29,7 +29,7 @@ Date: 9 Mar 2007 from __future__ import generators -import sys, warnings, os, fnmatch, glob, shutil, codecs, md5 +import sys, warnings, os, fnmatch, glob, shutil, codecs __version__ = '2.2' __all__ = ['path'] @@ -760,23 +760,6 @@ class path(_base): finally: f.close() - def read_md5(self): - """ Calculate the md5 hash for this file. - - This reads through the entire file. - """ - f = self.open('rb') - try: - m = md5.new() - while True: - d = f.read(8192) - if not d: - break - m.update(d) - finally: - f.close() - return m.digest() - # --- Methods for querying the filesystem. exists = os.path.exists diff --git a/tests/root/markup.txt b/tests/root/markup.txt index d16e57ef9..ceb74f63e 100644 --- a/tests/root/markup.txt +++ b/tests/root/markup.txt @@ -11,6 +11,11 @@ Testing various markup :author: Me :keywords: docs, sphinx +.. _label: + +:: + + some code Admonitions ----------- diff --git a/tests/test_build.py b/tests/test_build.py index 202ed8466..c1d859c0f 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -58,6 +58,7 @@ HTML_XPATH = { ".//meta[@name='author'][@content='Me']": '', ".//meta[@name='keywords'][@content='docs, sphinx']": '', ".//a[@href='contents.html#ref1']": '', + ".//div[@id='label']": '', }, 'desc.html': { ".//dt[@id='mod.Cls.meth1']": '', |