Skip to content

Gallery: one screenshot as HTML or Markdown (JS reference, SPEC, fixtures) (sc-9561) - #291

Merged
ndbroadbent merged 3 commits into
mainfrom
gallery-screenshot
Dec 5, 2026
Merged

ndbroadbent merged 3 commits into
mainfrom
gallery-screenshot

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

One screenshot from a gallery manifest, for a page or a README: screenshot(manifest, options) gives HTML, screenshotMarkdown(manifest, options) gives Markdown. Part of sc-9561. This is the JS reference, the SPEC section and the contract fixtures. The Ruby, Python, Rust and Hugo ports, the components and the docs page follow in later PRs.

  • Output: with no theme given and a dark shot for the screen, a <picture> with a <source media="(prefers-color-scheme: dark)">, so dark readers (GitHub's dark mode included) see the dark shot. Otherwise a plain <img> (with srcset when there's a 2x copy). Markdown gives ![alt](url) (or [![alt](url)](original)), and the <picture> HTML when there's a dark shot.
  • Options: screen (required), group, theme, size, alt, link, thumb, loading (lazy or eager), and the gallery's dimensions and groups.
  • Pairing reuses the gallery's model: buildModel runs on a manifest of the chosen group's items for that screen, so names pair exactly as they do in the gallery, and the gallery's errors apply to this screen alone. A screen with only 2x shots shows them at half size; otherwise its images are exactly the gallery's. Thumbs are used only when every image shown has one, and a dark source that is the same image is left out.
  • model.ts: two new exports, checkManifest and dimensionsOption (the dimensions option checked and resolved; buildModel uses it too). No behaviour change.
  • Fixtures (contract/screenshots): one manifest, 20 cases, each with exact .html and .md output (2x srcset, thumbs and mixed thumbs, 2x-only halving to odd sizes and past a name's width, a stray 2x shot, a theme-less screen, a custom dimension, the groups option, a duplicate group name, line breaks in alt, and escaping in alt and URL for both forms). 21 refusals with their messages, including the order of checks.

Nothing visible on the site yet. The changelog line comes with the docs page.

…k shot for dark readers (sc-9561)

screenshot() and screenshotMarkdown() in the JS library, the reference for the
other renderers: the SPEC's "A single screenshot" section and its fixtures in
contract/screenshots (cases with their HTML and Markdown, and refusals).
…can't end the Markdown image or HTML block; the SPEC names the gallery's messages for dimensions and groups (review)
…, thumbs only when every image shown has one, no dark source that's the same image; more fixtures (independent review)
@ndbroadbent
ndbroadbent merged commit 00f2415 into main Dec 5, 2026
17 checks passed
@ndbroadbent
ndbroadbent deleted the gallery-screenshot branch December 5, 2026 15:40
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