const markdownInclude = require('markdown-include')
const file = require('./file')
const markdown = {}
markdown.createTable = function (data, cols) {
let output = '
\n'
output += ' \n '
for (let column of cols) {
output += `${column.name} | `
}
output += '
\n \n'
output += ' \n'
for (let item of data) {
output += ' '
let i = 0
for (let prop in item) {
const column = cols[i]
let nowrap = column.nowrap
let align = column.align
output += `${item[prop]} | `
i++
}
output += '
\n'
}
output += ' \n'
output += '
'
return output
}
markdown.compile = function (filepath) {
markdownInclude.compileFiles(file.resolve(filepath))
}
module.exports = markdown