aphid 0.6.0

aphid 0.6.0 adds build-time SVG inlining. Content doesn’t change unless you opt in. Library users should note one renamed error variant, listed under Other changes.

Inline SVG images

An SVG shown through <img> is a separate document, so the page’s CSS can’t reach into it. Drawings that are generated without built-in styles therefore render unstyled, unless a theme script fetches each file and puts it into the DOM. That approach breaks without JavaScript and makes the page flash on load.

Now you can add #inline to the image URL:

![Wiring diagram for the A harness]/static/drawings/harness-a.svg#inline "The A harness"

aphid reads the file while building and writes its <svg> markup into the page, inside <figure class="inline-svg">:

  • The alt text becomes the drawing’s accessible name, and the title becomes a <figcaption>.
  • The XML prolog, doctype and comments are removed. The root <svg> attributes, class and viewBox among them, are kept for your CSS to target.
  • Each inlined SVG gets its own id prefix, and the references inside it are rewritten to match. Several drawings on one page don’t collide.
  • A missing or invalid file fails aphid build and names the page and the path. aphid serve warns instead, and when a generator rewrites an SVG, the dev server rebuilds and reloads the page.
  • Only files under /static/ are inlined. Remote URLs are never fetched, and paths that leave the static directory are rejected.

Images without the fragment stay <img>, and GitHub and other CommonMark viewers ignore it. See Markdown > inline-svg-images for the details and a styling example.

Other changes

  • The default theme gives inlined SVGs a responsive size and styles their captions.
  • For library users, Error::BrokenWikiLinks is now Error::Diagnostics, which carries every pass-1 problem (broken wiki-links and SVGs that can’t be inlined) so that a single build reports all of them. Diagnostics::ensure_clean() applies the build policy.

Upgrading

cargo install aphid --locked --force
aphid --version

For a containerised site, bump the image tag:

FROM ghcr.io/lhelge/aphid-server:0.6.0
COPY dist /site