##// END OF EJS Templates
Use int style instead of string....
Richard Everson -
Show More
@@ -121,28 +121,30 b' def single_ansi2latex(code):'
121 121 """
122 122 components = code.split(';')
123 123 if len(components) > 1:
124 style = components[0][-1]
124 # Style is digits after '['
125 style = int(components[0].split('[')[-1])
125 126 color = components[1][:-1]
126 127 else:
127 style = '0'
128 style = 0
128 129 color = components[0][-3:-1]
129 130
130 131 # If the style is not normal (0), bold (1) or blinking (5) then treat it as normal
131 if style not in '015':
132 style = '0'
132 if style not in [0, 1, 5]:
133 style = 0
133 134
134 135 for name, tcode in coloransi.color_templates:
135 136 tstyle, tcolor = tcode.split(';')
137 tstyle = int(tstyle)
136 138 if tstyle == style and tcolor == color:
137 139 break
138 140 else:
139 141 return '', 0
140 142
141 if style == '5':
143 if style == 5:
142 144 name = name[5:] # BlinkRed -> Red, etc
143 145 name = name.lower()
144 146
145 if style in '15':
147 if style in [1, 5]:
146 148 return r'\textbf{\color{'+name+'}', 1
147 149 else:
148 150 return r'{\color{'+name+'}', 1
@@ -173,5 +175,3 b' def ansi2latex(text):'
173 175 if openbrack:
174 176 outstring += '}'*openbrack
175 177 return outstring.strip()
176
177
@@ -76,7 +76,9 b' class TestAnsi(TestsBase):'
76 76 'hel%slo' % TermColors.Green : r'hel{\color{green}lo}',
77 77 'hello' : 'hello',
78 78 u'hello\x1b[34mthere\x1b[mworld' : u'hello{\\color{blue}there}world',
79 u'hello\x1b[mthere': u'hellothere'
79 u'hello\x1b[mthere': u'hellothere',
80 u'hello\x1b[01;34mthere' : u"hello\\textbf{\\color{lightblue}there}",
81 u'hello\x1b[001;34mthere' : u"hello\\textbf{\\color{lightblue}there}"
80 82 }
81 83
82 84 for inval, outval in correct_outputs.items():
General Comments 0
You need to be logged in to leave comments. Login now