<md-embed>
live Markdown, streamed into place.

Every block of prose on this page is Markdown in R2, rendered at request time by a Cloudflare Worker. Edit the file — the page updates. No redeploy.

npm i @dxj.jp/md-embed

docs/intro.md

What is this?

md-embed is a streaming shortcode renderer for Cloudflare Workers. You write a custom element in plain HTML:

<md-embed src="docs/intro.md"></md-embed>

and the Worker resolves it while the page streams — fetching this very Markdown from R2, rendering ## into <h2>, and stamping provenance attributes (rendered, data-md-src, data-md-etag) onto the element you're reading right now.

Open DevTools and inspect this block: the <md-embed> element is still there, carrying the ETag of the R2 object it came from.

The whole integration is three lines of Hono:

const app = new Hono<{ Bindings: Env }>();
app.use(mdEmbed<Env>((env) => r2Resolver(env.CONTENT)));
app.get("*", (c) => c.env.ASSETS.fetch(c.req.raw));

docs/features.md

Why it exists

Property How
Live content Markdown lives in R2, edited by humans and AI agents
Instant updates Upstream ETag / Content-Length are stripped, so browsers never revalidate into stale embeds
Streaming HTMLRewriter transforms the page as it streams — no buffering
Contained failures A broken embed stamps data-md-error and keeps its fallback; the page survives
One tag <md-embed> is the entire integration surface

This table is GFM Markdown, rendered server-side. The raw source is one click away: /raw/docs/features.md — the same content negotiated for machines.

docs/live-demo.md — edit it in R2 and reload

Live from R2 — updated!

This block was just edited in R2 (2026-07-21, right after the initial deploy) — no rebuild, no redeploy, and you are reading the new version.

That round-trip — wrangler r2 object put → reload — is the whole point:

  • Humans edit docs without touching CI
  • AI agents write content the same way
  • Every embedding page reflects it on the next request

docs/does-not-exist.md — graceful degradation

This fallback stays because the source is missing — inspect this element to see data-md-error="not-found". One broken embed never breaks the page.