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