Skip to content

Support @page named selectors, selector lists, size, and the page property - #214

Merged
TylerBrinks merged 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/paged-media
Jul 23, 2026
Merged

Support @page named selectors, selector lists, size, and the page property#214
TylerBrinks merged 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/paged-media

Conversation

@jhaygood86

Copy link
Copy Markdown
Contributor

Feature

CSS Paged Media 3 named page selectors, selector lists, the size descriptor and the page property:

@page chapter { margin: 1cm; }
@page chapter1:left, chapter2:left { margin: 1cm; }
@page { size: A4; }
@page { size: 8.5in 11in; }
.cover { page: chapter; }

On master, @page accepts only a single :pseudo selector — a named page or a selector list is dropped — and neither size nor page is recognised.

Implementation

  • PageSelector now holds a list of PageSelectorEntry (Name + Pseudo), and CreatePageSelector parses the §4.1 grammar per comma-separated entry: an optional <ident> page name then an optional :<ident> pseudo-class. @page :left still works.
  • The size @page descriptor (§6.3) — a page-size/orientation keyword (A4, letter, landscape) or one or two lengths — and the page property (§3.4), with StyleDeclaration.Size / PageName accessors.

Tests

14 cases in PropertyTests/PageRuleTests.cs: six selector forms (pseudo-only, name-only, name+pseudo, multi-entry lists), the exposed PageSelectorEntry list, five size values, and the page property.

The full suite (1263 existing tests) stays green — including the existing @page :left { size:A4; … @bottom-right{…} } test — and all seven target frameworks build with no new warnings.

PageSelector's constructor changed from PageSelector(string) to PageSelector(IEnumerable<PageSelectorEntry>). It's a public type; flagging the source-compat change, though nothing in the library or tests constructed it directly.

…perty

@page only accepted a single ":pseudo" selector, so a named page
("@page chapter") or a selector list ("@page chapter1:left,
chapter2:left") was dropped, and neither the "size" descriptor nor the
"page" property was recognised.

Rewrite PageSelector to hold a list of PageSelectorEntry (name + pseudo),
and CreatePageSelector to parse the CSS Paged Media 3 4.1 grammar per
comma-separated entry. Add the "size" @page descriptor
(a page-size/orientation keyword or one or two lengths) and the "page"
property, with StyleDeclaration.Size / PageName accessors.
@jhaygood86
jhaygood86 marked this pull request as ready for review July 22, 2026 23:27
@TylerBrinks
TylerBrinks merged commit df01452 into TylerBrinks:master Jul 23, 2026
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