fix: markdown tables drop empty cells and misalign columns (#1164)

* refactor: extract splitTableRow helper for markdown tables

* fix: keep empty interior cells in markdown tables to preserve columns

* test: splitTableRow keeps empty interior cells
This commit is contained in:
Afonso Coutinho
2026-06-02 14:41:27 +01:00
committed by GitHub
parent 6063fc51e0
commit 15a2662119
3 changed files with 67 additions and 1 deletions

View File

@@ -5,6 +5,7 @@
*/
import uiModule from './ui.js';
import { splitTableRow } from './markdown/tableRow.js';
var escapeHtml = uiModule.esc;
@@ -535,7 +536,7 @@ export function mdToHtml(src) {
let html = '<table style="border-collapse: collapse; width: 100%; margin: 10px 0;">';
rows.forEach((row, idx) => {
const cells = row.split('|').filter(cell => cell.trim() !== '');
const cells = splitTableRow(row);
if (cells.length === 0) return;
html += idx === 1 ? '<tbody>' : '';