mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
parent
64ead3b714
commit
0289f389d7
@ -304,18 +304,15 @@ export function exportHTML() {
|
||||
*/
|
||||
export function createTable({ data, rows, cols }) {
|
||||
let table = ``
|
||||
let currRow = []
|
||||
for (let i = 0; i < rows + 2; ++i) {
|
||||
table += `|\t`
|
||||
currRow = []
|
||||
table += `| `
|
||||
const currRow = []
|
||||
for (let j = 0; j < cols; ++j) {
|
||||
const rowIdx = i > 1 ? i - 1 : i
|
||||
i === 1
|
||||
? currRow.push(`---\t`)
|
||||
: currRow.push(data[`k_${rowIdx}_${j}`] || ``)
|
||||
currRow.push(i === 1 ? `---` : data[`k_${rowIdx}_${j}`] || ` `)
|
||||
}
|
||||
table += currRow.join(`\t|\t`)
|
||||
table += `\t|\n`
|
||||
table += currRow.join(` | `)
|
||||
table += ` |\n`
|
||||
}
|
||||
|
||||
return table
|
||||
|
Loading…
Reference in New Issue
Block a user