Permalink
Browse files

better html handling

  • Loading branch information...
1 parent e92af37 commit 300c827a36a5a34582b41fd2137205ecc6dd407e Tim Becker committed May 3, 2012
Showing with 17 additions and 6 deletions.
  1. +14 −3 hexy.js
  2. +1 −1 package.json
  3. +2 −2 test.js
View
17 hexy.js
@@ -111,7 +111,6 @@
// In case you discover bugs, spelling errors, offer suggestions for
// improvements or would like to help out with the project, you can contact
// me directly (tim@kuriositaet.de).
-
var hexy = function (buffer, config) {
config = config || {}
var h = new Hexy(buffer, config)
@@ -255,9 +254,21 @@ var Hexy = function (buffer, config) {
return s
}
var rpad = function(s, len) {
- while(s.length < len) {
- s += " "
+ for (var n = len - s.length; n!=0; --n) {
+ if (self.html) {
+ s += "&nbsp;"
+ } else {
+ s += " "
+ }
+
}
+// while(s.length < len) {
+// if (self.html) {
+// s += "&nbsp;"
+// } else {
+// s += " "
+// }
+// }
return s
}
View
@@ -1,6 +1,6 @@
{
"name" : "hexy",
- "version" : "0.2.2",
+ "version" : "0.2.3",
"description" : "hexdump, binary pretty-printing",
"author" : "Tim Becker <tim.becker@kuriositaet.de>",
"main" : "./hexy.js",
View
@@ -56,7 +56,7 @@ var results = [
"<div class='hexy'>\n"+
"<div class='00000000 even'>00000000: 3031 3233 3435 3637 3839 6162 6364 6566 0123456789abcdef</div>\n"+
"<div class='00000010 odd'>00000010: 6768 696a 6b6c 6d6e 6f70 7172 7374 7576 ghijklmnopqrstuv</div>\n"+
-"<div class='00000020 even'>00000020: 7778 7a79 wxzy</div>\n"+
+"<div class='00000020 even'>00000020: 7778 7a79 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wxzy</div>\n"+
"</div>\n",
]
@@ -120,7 +120,7 @@ failed += check(xxd3, hexy.hexy(str3))
xxd4 = "<div class='hexy'>\n"+
"<div class='00000000 even'>00000000: 2369 6e63 6c75 6465 3c73 7464 696f 2e68 #include&lt;stdio.h</div>\n"+
- "<div class='00000010 odd'>00000010: 3e0a &gt;.</div>\n"+
+ "<div class='00000010 odd'>00000010: 3e0a &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;.</div>\n"+
"</div>\n"
failed += check(xxd4, hexy.hexy(str3, {html:true}))

0 comments on commit 300c827

Please sign in to comment.