Embed Raku

One script tag turns code on your page into a real, running Raku editor. It works on any host — a blog, a documentation site, a conference slide deck.

Load the script

Anywhere in the page. Nothing to install, no build step, no npm.

<script src="https://raku.online/raku.js"></script>

Mark the code

Any element carrying data-raku becomes editable and runnable.

<pre data-raku>say "Hello from an embedded editor!";</pre>

That markup renders this — go ahead and change it:

say "Hello from an embedded editor!";

For an empty editor to type into instead, use an empty element:

<div data-raku data-run></div>

Already have Raku code blocks?

Add data-auto to the script tag and every existing <pre><code class="language-raku"> block on the page becomes runnable. You change nothing else — this is the shape Markdown, Prism, highlight.js and the WordPress code block already emit.

<script src="https://raku.online/raku.js" data-auto></script>

If your highlighter uses a different language name, name it: data-auto="raku perl6".

Options

All optional. The first three go on the block, the rest on the script tag.

data-runRun once, as soon as the interpreter is ready.
data-stdin="…"Preset standard input, and reveal the input box.
data-rows="N"Initial editor height in text rows. Defaults to fitting the code.
data-theme="dark"A page-wide default. Otherwise editors follow the host page's theme, live.
data-selector="…"Use your own selector instead of [data-raku].

Three things worth knowing

Next