Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support CSS border-spacing on tables#1321

Merged
odrobnik merged 1 commit into
developfrom
claude/lucid-montalcini-ae993c
Jun 12, 2026
Merged

Support CSS border-spacing on tables#1321
odrobnik merged 1 commit into
developfrom
claude/lucid-montalcini-ae993c

Conversation

@odrobnik

Copy link
Copy Markdown
Collaborator

Summary

border-spacing was declared in default.css but never consumed by the table parser — only the legacy cellspacing attribute worked — and the HTML writer never emitted cell spacing, so any spacing was silently lost on an HTML → attributed string → HTML round trip (e.g. cellspacing="10" came back as the 1px default).

  • Parser (BuilderState+Tables.swift): handleTableStart now reads border-spacing from the CSS cascade (inline styles and stylesheets), supporting the one-value and two-value (horizontal vertical) forms. Precedence follows browsers: border-collapse: collapse forces zero spacing, CSS border-spacing beats the cellspacing attribute, and the 0.5pt-margin importer default applies otherwise. Cell margins are tracked per axis, so asymmetric spacing lays out correctly (layout already reads margins per edge).
  • Writer (HTMLWriter.swift): the <table> tag emits border-spacing (first cell's margins × 2) whenever it differs from the 1px default, collapsed to one value when both axes match. Collapsed tables skip it.
  • default.css: removed the dead border-spacing: 2px declaration. Now that the property is honored, the merged cascade cannot distinguish UA-origin from author-origin styles, so keeping it would override every cellspacing attribute and change the plain-table default away from the Apple-importer-parity 0.5pt margin pinned by TextBlockAppKitParityTests.

Test plan

  • New parsing test: one-value and two-value border-spacing, CSS-over-attribute precedence, and collapse-ignores-spacing.
  • New round-trip test: cellspacing="10" is written as border-spacing:10px and reparses to 5pt margins; border-spacing: 8px 4px survives asymmetrically; default tables emit no border-spacing.
  • Full suite: 301 tests in 30 suites pass, including the AppKit parity and system-importer comparison suites.

🤖 Generated with Claude Code

The parser only honored the legacy cellspacing attribute; the
border-spacing property was ignored from any source, even though
default.css declared it, and the writer never emitted cell spacing, so
it was lost on every HTML round trip.

- Parse border-spacing (one- and two-value forms) from the cascade,
  with browser precedence: border-collapse:collapse forces zero, CSS
  beats the cellspacing attribute, falling back to the 0.5pt margin
  importer default. Margins are now tracked per axis so asymmetric
  spacing lays out correctly.
- Emit border-spacing on the table tag when the cells' margins differ
  from the default, so cellspacing/border-spacing survives writing.
- Remove the dead border-spacing declaration from default.css: with
  the property now honored, the merged cascade would let it override
  every cellspacing attribute and the Apple-parity 0.5pt default.

Co-Authored-By: Claude Fable 5 <[email protected]>
@odrobnik odrobnik merged commit 2497b97 into develop Jun 12, 2026
2 checks passed
@odrobnik odrobnik deleted the claude/lucid-montalcini-ae993c branch June 13, 2026 06:26
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