array-to-html
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -28,6 +28,6 @@ "use strict"; | ||
let bodyPiece = ''; | ||
let itemOfArray; | ||
let itemOfArray = null; | ||
let widthTd = ''; | ||
let hasColumSize = true; | ||
let renderer; | ||
let renderer = (el) => el; | ||
minify || (minify = false); | ||
@@ -63,8 +63,9 @@ fake_style || (fake_style = false); | ||
if (hasColumSize) { | ||
widthTd = columns_size[e] < 1 ? '' : ` width: ${columns_size[e]}%`; | ||
widthTd = columns_size[e] < 1 ? '' : `width: ${columns_size[e]}%`; | ||
} | ||
if (headerFind === null || headerFind === void 0 ? void 0 : headerFind.width) { | ||
widthTd = (headerFind === null || headerFind === void 0 ? void 0 : headerFind.width) < 1 ? '' : ` width: ${headerFind === null || headerFind === void 0 ? void 0 : headerFind.width}%`; | ||
widthTd = (headerFind === null || headerFind === void 0 ? void 0 : headerFind.width) < 1 ? '' : `width: ${headerFind === null || headerFind === void 0 ? void 0 : headerFind.width}%`; | ||
hasColumSize = true; | ||
} | ||
bodyPiece += `<td ${createFakeStyle(fake_style, 'tbody_td', widthTd)}> ${renderer(itemOfArray[headerKeys[e]])} </td> `; | ||
bodyPiece += `<td ${createFakeStyle(fake_style, 'tbody_td', widthTd)}> ${renderer(itemOfArray[headerKeys[e] || ''])} </td> `; | ||
} | ||
@@ -82,3 +83,3 @@ body += ` | ||
table = ` | ||
<table ${createFakeStyle(fake_style, 'table')}> | ||
<table ${createFakeStyle(fake_style, 'table', hasColumSize ? 'width: 100%' : '')}> | ||
${headerHtml} | ||
@@ -89,3 +90,4 @@ ${body} | ||
table = table.replace(/\s\s/g, ''); | ||
table = table.replace(/\n/g, ''); | ||
table = table.replace(/[\n\t]/g, ''); | ||
table = table.replace(/ >/g, '>'); | ||
} | ||
@@ -92,0 +94,0 @@ return table; |
{ | ||
"name": "array-to-html", | ||
"description": "Convert an array of objects to a simple markdown table.", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"main": "lib/array-to-html.js", | ||
@@ -6,0 +6,0 @@ "author": "natancabral", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21888
211