correctly detect a numeric color argument
This commit is contained in:
parent
201e28b256
commit
c8a24b0aa8
1 changed files with 5 additions and 1 deletions
|
|
@ -197,7 +197,7 @@ def colorin(text, color="red", style="normal"):
|
||||||
color_code = str(30 + colors[color])
|
color_code = str(30 + colors[color])
|
||||||
|
|
||||||
# 256 colors mode
|
# 256 colors mode
|
||||||
elif isinstance( color, int ):
|
elif color.isdigit():
|
||||||
mode = 256
|
mode = 256
|
||||||
color_nb = int(color)
|
color_nb = int(color)
|
||||||
assert(0 <= color_nb <= 255)
|
assert(0 <= color_nb <= 255)
|
||||||
|
|
@ -221,6 +221,10 @@ def colorin(text, color="red", style="normal"):
|
||||||
# because Pygments adds a newline char.
|
# because Pygments adds a newline char.
|
||||||
return highlight(text, lexer, formatter)[:-1]
|
return highlight(text, lexer, formatter)[:-1]
|
||||||
|
|
||||||
|
# unrecognized
|
||||||
|
else:
|
||||||
|
raise Exception('Unrecognized color %s' % color)
|
||||||
|
|
||||||
return start + style_code + endmarks[mode] + color_code + "m" + text + stop
|
return start + style_code + endmarks[mode] + color_code + "m" + text + stop
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue