Comparing version 1.0.0 to 1.0.1
@@ -37,3 +37,3 @@ var htmlStyles = { | ||
HtmlSerializer.prototype.serialize = function (lines) { | ||
return '<div style="font-family: monospace">\n' + this.serializeLines(lines) + '\n</div>'; | ||
return '<div style="font-family: monospace; white-space: nowrap">\n' + this.serializeLines(lines) + '\n</div>'; | ||
}; | ||
@@ -40,0 +40,0 @@ |
@@ -241,31 +241,4 @@ /*global window*/ | ||
function callculateLineSize(line) { | ||
var size = { height: 1, width: 0 }; | ||
line.forEach(function (outputEntry) { | ||
switch (outputEntry.style) { | ||
case 'text': | ||
size.width += String(outputEntry.args[0]).length; | ||
break; | ||
case 'block': | ||
var blockSize = calculateSize(outputEntry.args[0]); | ||
size.width += blockSize.width; | ||
size.height = Math.max(blockSize.height, size.height); | ||
break; | ||
} | ||
}); | ||
return size; | ||
} | ||
function calculateSize(lines) { | ||
var size = { height: 0, width: 0 }; | ||
lines.forEach(function (line) { | ||
var lineSize = callculateLineSize(line); | ||
size.height += lineSize.height; | ||
size.width = Math.max(size.width, lineSize.width); | ||
}); | ||
return size; | ||
} | ||
MagicPen.prototype.size = function () { | ||
return calculateSize(this.output); | ||
return utils.calculateSize(this.output); | ||
}; | ||
@@ -272,0 +245,0 @@ |
@@ -1,2 +0,2 @@ | ||
module.exports = { | ||
var utils = { | ||
extend: function (target) { | ||
@@ -10,3 +10,32 @@ var sources = Array.prototype.slice.call(arguments, 1); | ||
return target; | ||
}, | ||
calculateLineSize: function (line) { | ||
var size = { height: 1, width: 0 }; | ||
line.forEach(function (outputEntry) { | ||
switch (outputEntry.style) { | ||
case 'text': | ||
size.width += String(outputEntry.args[0]).length; | ||
break; | ||
case 'block': | ||
var blockSize = utils.calculateSize(outputEntry.args[0]); | ||
size.width += blockSize.width; | ||
size.height = Math.max(blockSize.height, size.height); | ||
break; | ||
} | ||
}); | ||
return size; | ||
}, | ||
calculateSize: function (lines) { | ||
var size = { height: 0, width: 0 }; | ||
lines.forEach(function (line) { | ||
var lineSize = utils.calculateLineSize(line); | ||
size.height += lineSize.height; | ||
size.width = Math.max(size.width, lineSize.width); | ||
}); | ||
return size; | ||
} | ||
}; | ||
module.exports = utils; |
@@ -190,3 +190,3 @@ /*! | ||
HtmlSerializer.prototype.serialize = function (lines) { | ||
return '<div style="font-family: monospace">\n' + this.serializeLines(lines) + '\n</div>'; | ||
return '<div style="font-family: monospace; white-space: nowrap">\n' + this.serializeLines(lines) + '\n</div>'; | ||
}; | ||
@@ -486,31 +486,4 @@ | ||
function callculateLineSize(line) { | ||
var size = { height: 1, width: 0 }; | ||
line.forEach(function (outputEntry) { | ||
switch (outputEntry.style) { | ||
case 'text': | ||
size.width += String(outputEntry.args[0]).length; | ||
break; | ||
case 'block': | ||
var blockSize = calculateSize(outputEntry.args[0]); | ||
size.width += blockSize.width; | ||
size.height = Math.max(blockSize.height, size.height); | ||
break; | ||
} | ||
}); | ||
return size; | ||
} | ||
function calculateSize(lines) { | ||
var size = { height: 0, width: 0 }; | ||
lines.forEach(function (line) { | ||
var lineSize = callculateLineSize(line); | ||
size.height += lineSize.height; | ||
size.width = Math.max(size.width, lineSize.width); | ||
}); | ||
return size; | ||
} | ||
MagicPen.prototype.size = function () { | ||
return calculateSize(this.output); | ||
return utils.calculateSize(this.output); | ||
}; | ||
@@ -599,3 +572,3 @@ | ||
},{}],6:[function(require,module,exports){ | ||
module.exports = { | ||
var utils = { | ||
extend: function (target) { | ||
@@ -609,5 +582,34 @@ var sources = Array.prototype.slice.call(arguments, 1); | ||
return target; | ||
}, | ||
calculateLineSize: function (line) { | ||
var size = { height: 1, width: 0 }; | ||
line.forEach(function (outputEntry) { | ||
switch (outputEntry.style) { | ||
case 'text': | ||
size.width += String(outputEntry.args[0]).length; | ||
break; | ||
case 'block': | ||
var blockSize = utils.calculateSize(outputEntry.args[0]); | ||
size.width += blockSize.width; | ||
size.height = Math.max(blockSize.height, size.height); | ||
break; | ||
} | ||
}); | ||
return size; | ||
}, | ||
calculateSize: function (lines) { | ||
var size = { height: 0, width: 0 }; | ||
lines.forEach(function (line) { | ||
var lineSize = utils.calculateLineSize(line); | ||
size.height += lineSize.height; | ||
size.width = Math.max(size.width, lineSize.width); | ||
}); | ||
return size; | ||
} | ||
}; | ||
module.exports = utils; | ||
},{}],7:[function(require,module,exports){ | ||
@@ -614,0 +616,0 @@ 'use strict'; |
{ | ||
"name": "magicpen", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Styled output in both consoles and browsers", | ||
@@ -5,0 +5,0 @@ "main": "./lib/MagicPen.js", |
@@ -359,3 +359,3 @@ /*global describe, it, beforeEach*/ | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div>><</div>\n' + | ||
@@ -369,3 +369,3 @@ '</div>' | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: red">Hello</span>' + | ||
@@ -381,3 +381,3 @@ ' ' + | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: red">Hello</span></div>\n' + | ||
@@ -391,3 +391,3 @@ ' <div><span style="color: green">world</span></div>\n' + | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: red">Hello</span></div>\n' + | ||
@@ -405,3 +405,3 @@ ' <div><span style="color: red">world</span></div>\n' + | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: red">Hello</span></div>\n' + | ||
@@ -416,3 +416,3 @@ ' <div> beautiful</div>\n' + | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: red"><foo & "bar"></span></div>\n' + | ||
@@ -429,3 +429,3 @@ '</div>'); | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: red">Danger</span> <span style="color: red">danger</span></div>\n' + | ||
@@ -440,3 +440,3 @@ '</div>'); | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div>Hello <span style="color: red">world!</span></div>\n' + | ||
@@ -454,3 +454,3 @@ '</div>'); | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: gray"> // </span>First line</div>\n' + | ||
@@ -469,4 +469,4 @@ ' <div><span style="color: gray"> // </span>Second line</div>\n' + | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
' <div><span style="color: red">Hello</span><div style="display: inline-block; vertical-align: top"><div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: red">Hello</span><div style="display: inline-block; vertical-align: top"><div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: gray"> // </span>This is a</div>\n' + | ||
@@ -486,3 +486,3 @@ ' <div><span style="color: gray"> // </span> multiline comment</div>\n' + | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: #bada55">Hello world</span></div>\n' + | ||
@@ -495,3 +495,3 @@ '</div>'); | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="background-color: #333">Hello world</span></div>\n' + | ||
@@ -504,3 +504,3 @@ '</div>'); | ||
expect(pen.removeFormatting().toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div>Hello world</div>\n' + | ||
@@ -587,3 +587,3 @@ '</div>'); | ||
expect(pen.toString('html'), 'to equal', | ||
'<div style="font-family: monospace">\n' + | ||
'<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div>' + | ||
@@ -733,3 +733,3 @@ '<span style="color: gray">H</span>' + | ||
writeFibWithPen(pen); | ||
expect(pen.toString('html'), 'to equal', '<div style="font-family: monospace">\n' + | ||
expect(pen.toString('html'), 'to equal', '<div style="font-family: monospace; white-space: nowrap">\n' + | ||
' <div><span style="color: black; font-weight: bold">function</span> <span style="color: red; font-weight: bold">fib</span> {</div>\n' + | ||
@@ -736,0 +736,0 @@ ' <div> <span style="color: black; font-weight: bold">var</span> i=0, fibs = [<span style="color: cyan">0</span>, <span style="color: cyan">1</span>];</div>\n' + |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
444001
2125