generated at
scrapbox記法のtableをmarkdownに変換する
GFMを使う

Markdownのテーブル記法
table.md
| header1 | header2 | | --| -- | | aaa | bbb | | ccc | ddd |


convertTable.js
function convertTable(tabel) { const line = [table.fileName]; // columnsの最大長を計算する const maxCol = Math.max(...table.cells.map(row => row.length)); table.cells.forEach((row, i) => { line.push(`| ${row.map(column => column.map(node =>convertNode(node)).join('')).join(' | '))} |`); if (i === 0) line.push(`| ${Array(maxCol).map(_ => '--').join(' | ')} |`); }); return line.join('\n'); }

Reference

#2020-10-16 07:49:04