Permalink
Browse files

make it recognize the case for [m.

  • Loading branch information...
dtinth committed May 16, 2013
1 parent e52e29d commit 6f0527c555287ec04ace27de3ffd0295ff8eb537
Showing with 4 additions and 2 deletions.
  1. +2 −2 lib/index.js
  2. +2 −0 test/index.js
View
@@ -49,12 +49,12 @@
return tag
}
- return str.replace(/\[(\d+;)?(\d+)+m/g, function(match, b1, b2) {
+ return str.replace(/\[(\d+;)?(\d+)*m/g, function(match, b1, b2) {
var i, code, res = ''
+ if (b2 == '' || b2 == null) b2 = '0'
for (i = 1; i < arguments.length - 2; i++) {
if (!arguments[i]) continue
code = parseInt(arguments[i])
-
res += tag(code)
}
return res
View
@@ -25,6 +25,8 @@ suite.addBatch(makeBatchFromTestCases(
, 'test[1mBold[32mGreen[31mRed[0mNone': 'test<span style="font-weight:bold">Bold</span><span style="font-weight:bold;color:green">Green</span><span style="font-weight:bold;color:red">Red</span>None'
, 'test[31mRed[1mBold[39mString': 'test<span style="color:red">Red</span><span style="color:red;font-weight:bold">Bold</span><span style="font-weight:bold">String</span>'
, 'test[42mGreenBG': 'test<span style="background:green">GreenBG</span>'
+, 'test[32mString[0mNone': 'test<span style="color:green">String</span>None'
+, 'test[32mString[mNone': 'test<span style="color:green">String</span>None'
}))
suite.export(module)

0 comments on commit 6f0527c

Please sign in to comment.