Skip to content

Add minimal table support#117

Open
tandav wants to merge 1 commit into
developit:mainfrom
tandav:add-tables
Open

Add minimal table support#117
tandav wants to merge 1 commit into
developit:mainfrom
tandav:add-tables

Conversation

@tandav

@tandav tandav commented Jul 15, 2026

Copy link
Copy Markdown

Adds GFM-style table parsing as a new tokenizer alternative and a single handler branch, keeping with snarkdown's one-regex design.

What it does

  • Consecutive lines starting with | are parsed as a <table>
  • If the second row is a separator (---, :---:), the first row renders as <th>; otherwise all cells are <td>
  • Cell content is parsed recursively, so inline formatting, links and code work inside cells

Implementation notes

  • The new capture group is appended to the end of the tokenizer regex, so all existing group indices are unchanged
  • Output is plain <table><tr><th>/<td> — no thead/tbody and no alignment handling, in keeping with the minimal footprint
  • Removes the README note saying tables are unsupported

Tests

Adds 4 tests (header table, headerless table, inline formatting in cells, table surrounded by text). Full suite passing: 37/37 under node:16.

Adds GFM-style table parsing as a new tokenizer alternative and a single handler branch, keeping with snarkdown's one-regex design.

## What it does

- Consecutive lines starting with `|` are parsed as a `<table>`
- If the second row is a separator (`---`, `:---:`), the first row renders as `<th>`; otherwise all cells are `<td>`
- Cell content is parsed recursively, so **inline formatting**, [links](#) and `code` work inside cells

## Implementation notes

- The new capture group is appended to the *end* of the tokenizer regex, so all existing group indices are unchanged
- Output is plain `<table><tr><th>`/`<td>` — no `thead`/`tbody` and no alignment handling, in keeping with the minimal footprint
- Removes the README note saying tables are unsupported

## Tests

Adds 4 tests (header table, headerless table, inline formatting in cells, table surrounded by text). Full suite passing: **37/37** under `node:16`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant