feat(convert): publish table cell background colors - #54
Merged
Conversation
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
force-pushed
the
table-cell-background-colors
branch
from
August 4, 2026 16:44
243f7ea to
a1daefd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7.
Authoring surface
A leading
<!-- bg:COLOR -->HTML comment in a GFM table cell sets that cell's background in Confluence: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.COLORis one of the 21 swatches from the Confluence editor's cell background picker, or a literal#rrggbbfor anything off-palette. Atlassian doesn't document the palette, so the hexes were read off an editor-authored page; notegreyis#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:
Implementation
tableCellBGTransformer(AST transformer, same shape ascalloutTransformer) consumes the marker, trims the whitespace it leaves behind, resolves the color, and stashes the hex on the cell node.renderTableCellemits it asdata-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.cellBGSwatchesis the name→hex map, with the palette's provenance recorded in a comment so nobody re-derives it.Testing
make test && make lint && make vetclean.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-bgcomment 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_formatback: all 21 swatches reach ADF as a cellbackgroundwith 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 noalignmentmarks 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.