Show More
@@ -284,27 +284,36 b' define([' | |||||
284 | function ansispan(str) { |
|
284 | function ansispan(str) { | |
285 | // ansispan function adapted from github.com/mmalecki/ansispan (MIT License) |
|
285 | // ansispan function adapted from github.com/mmalecki/ansispan (MIT License) | |
286 | // regular ansi escapes (using the table above) |
|
286 | // regular ansi escapes (using the table above) | |
|
287 | var is_open = false | |||
287 | return str.replace(/\033\[(0?[01]|22|39)?([;\d]+)?m/g, function(match, prefix, pattern) { |
|
288 | return str.replace(/\033\[(0?[01]|22|39)?([;\d]+)?m/g, function(match, prefix, pattern) { | |
288 | if (!pattern) { |
|
289 | if (!pattern) { | |
289 | // [(01|22|39|)m close spans |
|
290 | // [(01|22|39|)m close spans | |
290 |
|
|
291 | if (is_open) { | |
291 | } |
|
292 | is_open = false; | |
292 | // consume sequence of color escapes |
|
293 | return "</span>"; | |
293 | var numbers = pattern.match(/\d+/g); |
|
294 | } else { | |
294 | var attrs = {}; |
|
295 | return ""; | |
295 | while (numbers.length > 0) { |
|
296 | } | |
296 | _process_numbers(attrs, numbers); |
|
297 | } else { | |
297 | } |
|
298 | is_open = true; | |
298 |
|
299 | |||
299 | var span = "<span "; |
|
300 | // consume sequence of color escapes | |
300 | for (var attr in attrs) { |
|
301 | var numbers = pattern.match(/\d+/g); | |
301 |
var |
|
302 | var attrs = {}; | |
302 | span = span + " " + attr + '="' + attrs[attr] + '"'; |
|
303 | while (numbers.length > 0) { | |
|
304 | _process_numbers(attrs, numbers); | |||
|
305 | } | |||
|
306 | ||||
|
307 | var span = "<span "; | |||
|
308 | for (var attr in attrs) { | |||
|
309 | var value = attrs[attr]; | |||
|
310 | span = span + " " + attr + '="' + attrs[attr] + '"'; | |||
|
311 | } | |||
|
312 | return span + ">"; | |||
303 | } |
|
313 | } | |
304 | return span + ">"; |
|
|||
305 | }); |
|
314 | }); | |
306 | }; |
|
315 | }; | |
307 |
|
316 | |||
308 | // Transform ANSI color escape codes into HTML <span> tags with css |
|
317 | // Transform ANSI color escape codes into HTML <span> tags with css | |
309 | // classes listed in the above ansi_colormap object. The actual color used |
|
318 | // classes listed in the above ansi_colormap object. The actual color used | |
310 | // are set in the css file. |
|
319 | // are set in the css file. |
General Comments 0
You need to be logged in to leave comments.
Login now