diff --git a/CHANGES b/CHANGES index b22a0c1d4..f21472f33 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,7 @@ Features added Bugs fixed ---------- * Remove ``image/gif`` from supported_image_types of LaTeX writer (#2272) +* Fix code-block literals raises highlighting warnings by default Documentation ------------- diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index 37efdc887..40c83260e 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -144,17 +144,17 @@ class PygmentsBridge(object): if source.startswith('>>>'): # interactive session lexer = lexers['pycon'] - elif not force: - # maybe Python -- try parsing it - if self.try_parse(source): - lexer = lexers['python'] - else: - lexer = lexers['none'] else: lexer = lexers['python'] elif lang in ('py3', 'python3'): if source.startswith('>>>'): lexer = lexers['pycon3'] + elif not force: + # maybe Python -- try parsing it + if self.try_parse(source): + lexer = lexers['python3'] + else: + lexer = lexers['none'] else: lexer = lexers['python3'] elif lang == 'guess': diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 2729790ba..b1181fbeb 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -81,8 +81,8 @@ HTML_XPATH = { (".//pre", u'Max Strauß'), (".//a[@href='_downloads/img.png']", ''), (".//a[@href='_downloads/img1.png']", ''), - (".//pre", u'"quotes"'), - (".//pre", u"'included'"), + (".//pre/span", u'"quotes"'), + (".//pre/span", u"'included'"), (".//pre/span[@class='s2']", u'üöä'), (".//div[@class='inc-pyobj1 highlight-text']//pre", r'^class Foo:\n pass\n\s*$'),