Skip to content

Commit

Permalink
Fix code highlighting on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Sep 11, 2020
1 parent a6a7b7f commit 15cb51b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions xdoctest/utils/util_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,14 @@ def highlight_code(text, lexer_name='python', **kwargs):
'cxx': 'cpp',
'c': 'cpp',
}.get(lexer_name.replace('.', ''), lexer_name)
import os
if os.environ.get('XDOC_WIN32_COLORS', 'False') == 'False':
# hack: dont color on windows by default, but do init colorama
return text

if sys.platform.startswith('win32'): # nocover
# Hack on win32 to support colored output
import os
if os.environ.get('XDOC_WIN32_COLORS', 'False') == 'False':
# hack: dont color on windows by default, but do init colorama
return text

try:
import pygments
import pygments.lexers
Expand Down

0 comments on commit 15cb51b

Please sign in to comment.