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 }) {
|
export function createTable({ data, rows, cols }) {
|
||||||
let table = ``
|
let table = ``
|
||||||
let currRow = []
|
|
||||||
for (let i = 0; i < rows + 2; ++i) {
|
for (let i = 0; i < rows + 2; ++i) {
|
||||||
table += `|\t`
|
table += `| `
|
||||||
currRow = []
|
const currRow = []
|
||||||
for (let j = 0; j < cols; ++j) {
|
for (let j = 0; j < cols; ++j) {
|
||||||
const rowIdx = i > 1 ? i - 1 : i
|
const rowIdx = i > 1 ? i - 1 : i
|
||||||
i === 1
|
currRow.push(i === 1 ? `---` : data[`k_${rowIdx}_${j}`] || ` `)
|
||||||
? currRow.push(`---\t`)
|
|
||||||
: currRow.push(data[`k_${rowIdx}_${j}`] || ``)
|
|
||||||
}
|
}
|
||||||
table += currRow.join(`\t|\t`)
|
table += currRow.join(` | `)
|
||||||
table += `\t|\n`
|
table += ` |\n`
|
||||||
}
|
}
|
||||||
|
|
||||||
return table
|
return table
|
||||||
|
Loading…
Reference in New Issue
Block a user