Skip to content

Autoflow rule: bare-image-position-variation

Priority 70 · A bare ![](src) with more than 8 words varies position across the deck: inline → left → right. With fewer words it becomes a filtered hero background.

This is the only rule that uses cross-slide state. Every other rule treats each slide independently. This one looks at the position used for the previous bare image in the deck and picks the next position in the cycle.

The name says “position variation” because it varies the image position across slides — it doesn’t rotate the image itself.

  • The slide has exactly 1 image with no layout modifier (no right / left / inline / qr / fit / filtered / bg / bordered)
  • The slide has more than 8 words of text beside it

With 8 words or fewer, the slide is a hero instead: the image becomes a ![filtered] background (dark overlay) and the words go through the text rules on top of it — usually a big #[fit] statement. The threshold is heroMaxWords in the autoflow config.

The rule reads ctx.state.lastBareImagePosition and picks the next position in the cycle:

1st bare image in deck → inline (image in flow, source order)
2nd bare image in deck → left (split, image left + text right)
3rd bare image in deck → right (split, image right + text left)
4th → inline, 5th → left, 6th → right, ...

inline stacks image and text in one column, so it’s only picked when the text is at most two lines (a title and one line). With more text the variation alternates left / right.

All three are existing parser primitives — the rule rewrites the bare ![](src) into one of ![inline](src) / ![left](src) / ![right](src) and the parser handles the rest.

The variation persists across the entire deck via ctx.state, not just within the current slide. Even if other rules fire between two bare-image slides, the variation continues from where it left off.

Cross-slide observation: explicit images count too

Section titled “Cross-slide observation: explicit images count too”

The rule’s observe hook runs on every slide — even ones autoflow skips (because of #[fit], code blocks, etc) — and records explicit ![left] / ![right] / ![inline] images as if the variation had picked that position.

Why: a user-placed ![left](photo.jpg) and a bare ![](next-photo.jpg) on the next slide should not both end up on the left. Without this observation, the bare-image variation would happily ignore the explicit one and could pick the same position. With it, the rule treats explicit and bare images as one continuous variation history.

Concrete example:

slide 1: ![](a.jpg) → rule rewrites to ![inline](a.jpg) (lastPosition = inline)
slide 2: ![left](b.jpg) → explicit, left as written; observed (lastPosition = left)
slide 3: ![](c.jpg) → rule picks NEXT after left = right (lastPosition = right)

Slide 3 would have been left again without the observation step.

Without it, an author with several plain ![](src) slides would have to manually decide a position for each one. Forgetting to vary results in every photo on the same side, which feels mechanical. The variation gives natural rhythm without any thinking from the author.

The fixture below has 4 bare-image slides in a row: inline → left → right, then a hero (a few words over the image).

footer: autoflow rules · bare-image-position-variation
slidenumbers: true
autoflow: true
theme: nordic
scheme: 1
# Cover
(slide 0 — sets up the deck before the variation begins)
---
<!--
RULE: bare-image-position-variation (priority 70)
TRIGGERS WHEN:
- The slide has exactly 1 image with NO layout modifier
(no right/left/inline/qr/fit/filtered/bg/bordered)
- The slide has MORE text than a hero slide holds (> 8 words).
With 8 words or fewer, the image becomes a ![filtered] background
instead (the bare-image-background preprocessor) — see the last slide.
EFFECT (history-based):
- Picks position by varying across deck: inline → left → right → ...
- inline only when the text is at most 2 lines (title + one line);
with more text it alternates left/right so nothing gets pushed off
- The position is based on ctx.state.lastBareImagePosition, NOT slide index
- Rewrites the bare ![](src) into a parser primitive:
![inline](src), ![left](src), ![right](src)
- State is also updated when an EXPLICIT ![left]/![right]/![inline]
image appears on any slide, so neighbors never repeat a side.
The name says "position variation" because it varies the IMAGE POSITION
across slides — it doesn't rotate the image itself.
slide 1: 1st bare image → inline (title + one line)
slide 2: 2nd bare image → left
slide 3: 3rd bare image → right
slide 4: a few words → hero (filtered background), not a position
-->
![](/demo/images/vibe-coding/karpathy-vibe.webp)
# First image of the deck
A title and one line of text: the image goes inline.
---
![](/demo/images/vibe-coding/seven-languages-book.webp)
# Second image
More text than a hero slide holds,
so the image takes the left half of a split.
---
![](/demo/images/vibe-coding/pragmatic-programmer-tweet.webp)
# Third image
The next one alternates to the right,
so neighboring slides never repeat a side.
---
![](/demo/images/vibe-coding/bravenewgeek-you-are-not-paid.webp)
You are not paid
to write code.

A planned upgrade: measure the image at render time (naturalWidth/Height) and prefer portrait → split vs landscape → inline hero instead of strict round-robin variation. The CSS classes would be applied via a small JS helper in js/render.js, not in autoflow itself (which is sync markdown→markdown). Tracked in the roadmap.