Skip to content

Add full markdown table support#58

Merged
a-bonus merged 2 commits intoa-bonus:mainfrom
mtzirkel:feature/table-support
Feb 19, 2026
Merged

Add full markdown table support#58
a-bonus merged 2 commits intoa-bonus:mainfrom
mtzirkel:feature/table-support

Conversation

@mtzirkel
Copy link
Copy Markdown

Summary

  • Tables were previously no-ops — all table tokens were explicitly set to break in markdownToDocs.ts, so any markdown table was silently dropped
  • This patch implements full table support: inserts a correctly-sized table via the Google Docs insertTable API, then populates each cell with text and inline formatting
  • Header rows are automatically bolded

Implementation details

The core challenge is that the Google Docs API requires knowing all indices upfront before inserting text, and inserting content shifts all subsequent indices. The approach:

  1. Buffer cell content during token processing — store each cell's text runs (with inline formatting spans) into a TableState structure rather than emitting requests immediately
  2. On table_close — emit one insertTable request, then iterate all cells in order, tracking cumulative inserted character counts to compute correct absolute indices

Key index formulas (verified against the Docs API table structure):

cellContentIndex(T, r, c, C) = T + 4 + r * (1 + 2*C) + 2*c
emptyTableSize(R, C)         = 3 + R * (1 + 2*C)
currentIndex after table     = tableStartIndex + emptyTableSize + cumulativeTextLength

Testing

Tested with an 8-table document (mixed column counts, bold/italic inline formatting in cells) pushed to Google Drive via replaceDocumentWithMarkdown. All tables rendered correctly with bold header rows.

Before this patch, the same document produced garbled output with all table content concatenated into the surrounding paragraph text.

Notes

  • Only replaceDocumentWithMarkdown exercises the full transformer path — createDocument with contentFormat: "markdown" also works for tables via this same transformer
  • No changes to the public API or other markdown elements

Travis Miller and others added 2 commits February 18, 2026 15:07
Tables were previously no-ops (all table tokens explicitly set to
`break`). This patch implements complete table support:

- Inserts a properly-sized table via the Google Docs insertTable API
- Populates each cell with text content
- Supports inline formatting (bold, italic, links) within cells
- Applies bold formatting to header rows automatically
- Handles tables of arbitrary row/column count

Key index formulas verified against the Docs API structure:
  cellContentIndex(T, r, c, C) = T + 4 + r * (1 + 2*C) + 2*c
  emptyTableSize(R, C) = 3 + R * (1 + 2*C)

Tested with an 8-table document (mixed column counts) pushed to
Google Drive via replaceDocumentWithMarkdown — all tables rendered
correctly with bold headers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@a-bonus a-bonus merged commit 4b3008b into a-bonus:main Feb 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants