nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Markdown tables drop empty cells, so the rest of the row shifts into the wrong columns

Open inahus99 opened this issue 1 week ago • 0 comments

Description

A markdown table with an empty cell is rendered with the rest of that row shifted one column to the left. parseMarkdownTable splits each row on | and then drops every empty cell, which is meant to remove the two empty strings from the outer pipes but also removes cells that are really empty.

Environment

  • OS: Windows 11
  • Node version: v24.11.0
  • Nanocoder version: 1.32.0 (main at bfd8b8e7)
  • Provider: Not provider-specific
  • Model: Not model-specific

Steps to Reproduce

  1. Ask any model to reply with exactly this table:

    | Name | Age | City  |
    |------|-----|-------|
    | John |     | Paris |
    
  2. Look at the rendered table.

The same can be seen by calling parseMarkdownTable with that text directly.

Expected Behavior

John under Name, an empty Age cell, and Paris under City.

Actual Behavior

Paris is rendered under Age and the City column is empty. Two more cases with the same cause:

  • An empty first cell, | | 30 |, puts 30 under the first column.
  • An empty header corner cell, | | Mon | Tue |, shifts every header left, so the headers no longer line up with the data rows.

Tables with blank cells are common in model output (comparison and feature tables), so values end up under the wrong heading.

Logs/Screenshots

Cells of the rendered row, in column order:

row "| John |     | Paris |"   expected ['John', '', 'Paris']   actual ['John', 'Paris', '']
row "|      | 30  |"           expected ['', '30']              actual ['30', '']
header "|   | Mon | Tue |"     expected ['', 'Mon', 'Tue']      actual ['Mon', 'Tue', '']

The existing spec "parseMarkdownTable handles table with empty cells" only checks that the text appears somewhere in the output, so it passes either way.

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder

Cause: source/markdown-parser/table-parser.ts, the "Extract rows" step, .split('|').map(cell => cell.trim()).filter(cell => cell.length > 0).

Suggested fix: strip only the leading and trailing pipe of each line before splitting, and keep empty cells. I have this working locally with three specs that check each cell's column, and I would like to work on it if you can assign it to me.

inahus99 avatar Nov 22 '26 14:11 inahus99