Skip to content

Instantly share code, notes, and snippets.

View teoeter's full-sized avatar

Teo Et3r0v1c teoeter

  • Switzerland
View GitHub Profile
function tableToList(md: string): string {
return md.replace(/\|.+\n(\|[-:]+.*\n)(\|.+\n)+/g, block => {
const lines = block.trim().split('\n').filter(l => l.startsWith('|'));
const headers = split(lines[0]);
const rows = lines.slice(2).map(split);
return rows
.map(r => headers.map((h, i) => `- **${h}**: ${r[i] ?? ''}`).join('\n'))
.join('\n\n');
});
@teoeter
teoeter / ts
Created October 15, 2025 14:43
Table to list
function parseMarkdownTable(md: string) {
const lines = md.trim().split('\n').filter(l => l.startsWith('|'));
if (lines.length < 2) return [];
const headers = splitRow(lines[0]);
return lines.slice(2).map(line => {
const cells = splitRow(line);
return Object.fromEntries(headers.map((h, i) => [h, cells[i] ?? '']));
});