viewcode: default to python3 highlighting if highlight_language is python3

This commit is contained in:
Georg Brandl
2016-02-14 09:36:42 +01:00
parent c1b7b6f369
commit 23431eaf4e
+5 -1
View File
@@ -139,7 +139,11 @@ def collect_pages(app):
# construct a page name for the highlighted source
pagename = '_modules/' + modname.replace('.', '/')
# highlight the source using the builder's highlighter
highlighted = highlighter.highlight_block(code, 'python', linenos=False)
if env.config.highlight_language == 'python3':
lexer = 'python3'
else:
lexer = 'python'
highlighted = highlighter.highlight_block(code, lexer, linenos=False)
# split the code into lines
lines = highlighted.splitlines()
# split off wrap markup from the first line of the actual code