@@ -201,20 +201,27 @@ def get_page(command, remote=None, platform=None):
201201
202202DEFAULT_COLORS = {
203203 'blank' : 'white' ,
204- 'name' : 'white bold' ,
205- 'description' : 'white ' ,
204+ 'name' : 'bold' ,
205+ 'description' : '' ,
206206 'example' : 'green' ,
207207 'command' : 'red' ,
208- 'parameter' : 'white ' ,
208+ 'parameter' : '' ,
209209}
210210
211211# See more details in the README:
212212# https://github.com/tldr-pages/tldr-python-client#colors
213213ACCEPTED_COLORS = [
214214 'blue' , 'green' , 'yellow' , 'cyan' , 'magenta' , 'white' ,
215- 'grey' , 'red' , 'on_blue' , 'on_cyan' , 'on_magenta' , 'on_white' ,
216- 'on_grey' , 'on_yellow' , 'on_red' , 'on_green' , 'reverse' ,
217- 'blink' , 'dark' , 'concealed' , 'underline' , 'bold'
215+ 'grey' , 'red'
216+ ]
217+
218+ ACCEPTED_COLOR_BACKGROUNDS = [
219+ 'on_blue' , 'on_cyan' , 'on_magenta' , 'on_white' ,
220+ 'on_grey' , 'on_yellow' , 'on_red' , 'on_green'
221+ ]
222+
223+ ACCEPTED_COLOR_ATTRS = [
224+ 'reverse' , 'blink' , 'dark' , 'concealed' , 'underline' , 'bold'
218225]
219226
220227LEADING_SPACES_NUM = 2
@@ -225,17 +232,18 @@ def get_page(command, remote=None, platform=None):
225232
226233def colors_of (key ):
227234 env_key = 'TLDR_COLOR_%s' % key .upper ()
228- user_value = os .environ .get (env_key , '' ).strip ()
229- if user_value and user_value not in ACCEPTED_COLORS :
230- # you can put a warning statement here, but it will print a lot
231- user_value = None
232- values = user_value or DEFAULT_COLORS [key ]
233- values = values .split ()
234- return (
235- values [0 ] if len (values ) > 0 else None ,
236- values [1 ] if len (values ) > 1 and values [1 ].startswith ('on_' ) else None ,
237- values [2 :] if len (values ) > 1 and values [1 ].startswith ('on_' ) else values [1 :],
238- )
235+ values = os .environ .get (env_key , DEFAULT_COLORS [key ]).strip ().split ()
236+ color = None
237+ on_color = None
238+ attrs = []
239+ for value in values :
240+ if value in ACCEPTED_COLORS :
241+ color = value
242+ elif value in ACCEPTED_COLOR_BACKGROUNDS :
243+ on_color = value
244+ elif value in ACCEPTED_COLOR_ATTRS :
245+ attrs .append (value )
246+ return (color , on_color , attrs )
239247
240248
241249def output (page ):
0 commit comments