Skip to content

feat(convert): publish table cell background colors - #54

Merged
willkg merged 1 commit into
mainfrom
table-cell-background-colors
Aug 4, 2026
Merged

feat(convert): publish table cell background colors#54
willkg merged 1 commit into
mainfrom
table-cell-background-colors

Conversation

@willkg

@willkg willkg commented Aug 4, 2026

Copy link
Copy Markdown
Member

Fixes #7.

Authoring surface

A leading <!-- bg:COLOR --> HTML comment in a GFM table cell sets that cell's background in Confluence:

| Service | Status                     |
| ------- | -------------------------- |
| auth    | <!-- bg:light-green --> ok |
| billing | <!-- bg:light-red --> down |

An HTML comment won this over the alternatives (a delimiter-row extension, an in-cell {bg=…} token, a per-table directive) because it's invisible in a plain markdown preview and lives in the cell, so the color travels with the row when rows are moved, reordered, or copied — no coordinates to keep in sync.

COLOR is one of the 21 swatches from the Confluence editor's cell background picker, or a literal #rrggbb for anything off-palette. Atlassian doesn't document the palette, so the hexes were read off an editor-authored page; note grey is #b3bac5, and the picker's grey column runs white / light grey / grey rather than light/medium/bold. README has the full table.

Two cases are dropped with a warning rather than silently:

  • an unknown color name;
  • a marker that isn't the first thing in its cell. Confluence strips HTML comments on write, so a misplaced marker would otherwise vanish without a trace on the page.

Implementation

  • tableCellBGTransformer (AST transformer, same shape as calloutTransformer) consumes the marker, trims the whitespace it leaves behind, resolves the color, and stashes the hex on the cell node.
  • renderTableCell emits it as data-highlight-colour, otherwise reproducing goldmark's GFM cell output byte-for-byte — no existing golden changed. Cell alignment is untouched; that's still Table cell alignment is silently dropped when publishing #48.
  • cellBGSwatches is the name→hex map, with the palette's provenance recorded in a comment so nobody re-derives it.

Testing

make test && make lint && make vet clean.

New regression case table-cell-colors/ covers swatch names, hex, header cells, a marker-only (empty colored) cell, case-insensitivity, the unknown-name warning, the misplaced-marker warning, and a non-bg comment passing through untouched.

Verified live against Confluence, since storage persisting an attribute doesn't prove the renderer honors it. Published markfluence's own output and read body-format=atlas_doc_format back: all 21 swatches reach ADF as a cell background with the exact hex (21 checked, 0 mismatched), plus an off-palette hex, a colored header cell, and a marker-only empty cell. Both warning cases published uncolored, and no alignment marks appeared anywhere — #48 is unchanged, not made worse.

Scope note

Per the discussion on #7: table width and column widths aren't needed (PR #50 made the default better), and column alignment is #48. Cell background color was the remaining piece, so this closes #7.

A leading `<!-- bg:COLOR -->` HTML comment in a GFM table cell sets that
cell's background in Confluence. The comment is invisible in a markdown
preview, and being in the cell, the color travels with the row when rows
are moved or reordered.

COLOR is one of the 21 swatches the Confluence editor's cell background
picker offers, or a literal #rrggbb for anything off-palette. Atlassian
doesn't document the palette, so the swatch hexes were read off an
editor-authored page; `grey` is #b3bac5, and the grey column of the
picker runs white / light grey / grey rather than light/medium/bold.

An unknown color name is dropped with a warning, as is a marker that
isn't the first thing in its cell: Confluence strips HTML comments on
write, so a misplaced marker would otherwise disappear without a trace.

tableCellBGTransformer consumes the marker and stashes the resolved hex
on the cell node; renderTableCell emits it as data-highlight-colour and
otherwise reproduces what goldmark's GFM renderer emits, so no existing
golden changed. Cell alignment is untouched (issue #48).

Verified live on page 2942664752: all 21 swatches, an off-palette hex, a
colored header cell, and a marker-only empty cell reach ADF as a cell
background; both warning cases publish uncolored.

Fixes #7
@willkg
willkg force-pushed the table-cell-background-colors branch from 243f7ea to a1daefd Compare August 4, 2026 16:44
@willkg
willkg merged commit ed082be into main Aug 4, 2026
1 check passed
@willkg
willkg deleted the table-cell-background-colors branch August 4, 2026 16:44
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.

Support additional Confluence table features

1 participant