Finder Quick Look and thumbnails

Space, and there it is.

Select a PubMark or Markdown file in Finder and press Space. Galley's Quick Look extension renders it as a typeset page, offline, and its thumbnail extension gives Finder a drawn page with a corner badge for the icon.

Illustration: a single blank sheet of paper on a dark walnut desk under a round brass reading glass on a stand.
In Finder

What Finder shows

Both pictures are real. The panel is the Space bar in Finder on a fictional StrataForge document, and the thumbnails come from macOS's own thumbnail generator asking Galley's installed extension.

The Quick Look panel that Finder opens when Space is pressed on the StrataForge Actuator Telemetry Brief, a PubMark file: the deep navy masthead with the title, subtitle, authors, and keyword chips, over the abstract, the contents, and the first section, drawn by Galley's Quick Look extension.
Space on a PubMark file in Finder: the panel is Finder's and the page in it is Galley's. Captured with the Mac in Dark appearance, which Quick Look follows.
  • The Finder thumbnail of the StrataForge Actuator Telemetry Brief: a drawn page with the title, its subtitle, rules for the text, and tinted bars for the blocks, with a brass PUBMARK pill in the lower corner.
    A PubMark file: the PUBMARK pill.
  • The Finder thumbnail of the StrataForge Telemetry SDK README, a plain Markdown file: a drawn page with the title, rules for the text, and tinted bars for the blocks, with a blue MD pill in the lower corner.
    A Markdown file: the MD pill.
  • The Finder thumbnail of Galley's own Quick Look smoke-test file, as scripts/ql-smoke.sh makes it: a drawn page with the title, its subtitle, rules, and a tinted bar, with a brass PUBMARK pill in the lower corner.
    The repository's own smoke-test file, from its ql-smoke script's request.
The compound extension

Why .pub.md needs two registrations

To macOS, a file named report.pub.md has the extension md, so it is a Markdown file. A Quick Look extension that claims only a PubMark type never sees it, and one that claims only Markdown cannot tell it from any other note.

Galley handles both ends. It exports its own PubMark Document type, com.renkara.pubmark, which conforms to the Markdown type and to plain text, and declares both that type and the Markdown type in the preview extension's supported types and in the app's document types. At run time it decides a file is PubMark from its .pub.md or .pubmark name or from a pubmark front matter line, and treats anything else as Markdown.

Quick Look

A data-based preview with no network and no script

  • The extension parses the file, renders it with the same GalleyKit engine as the app, and hands Finder a finished HTML page as data. It never opens a web view of its own.
  • It carries the App Sandbox and the shared app group, and no network entitlement.
  • Its policy is the strictest Galley has: no raw HTML, no document stylesheets, no outside resources, and no relative file access. A strict content security policy with a fresh nonce is on every page.
  • The page has no script. What needs one stays plain in Quick Look: math is set as static type, a Mermaid diagram shows its source, and code is not highlighted. The app draws all three with its bundled KaTeX, Mermaid, and Highlight.js.
  • A file larger than the source cap (10 megabytes by default) is cut off rather than parsed whole, so a huge file cannot stall Finder.
  • Quick Look uses the template you choose for it in Settings. The default is Renkara Editorial.
Thumbnails

A page drawn in Core Graphics, in a process with no web view

  • The thumbnail extension reads at most the first 32 kilobytes of the file, parses them, and draws the title block and the shape of the blocks under it with Core Graphics and Core Text.
  • A pill in the corner says PUBMARK or MD, so a folder of mixed files tells you what each one is.
  • It never starts WebKit.
  • Thumbnails do not change with the appearance, so one picture serves both themes.
When it does not work

A health panel for Quick Look

Another Markdown Quick Look extension can claim the Markdown type ahead of Galley. Settings has a Quick Look tab that shows whether each of Galley's two extensions is registered and enabled, lists any competing Markdown extensions it finds, and opens the Quick Look pane of System Settings for you.

Contact

Questions about this tool?

Write to Renkara Media Group and a person will answer.