Plain HTML, Markdown or Solid

One playground three ways, with the source of each beside it.

Framework decisions behind it: D35, D55, D68, D69.

The same playground, written three ways. They differ only in how they are placed on the page: a custom element in HTML, a fenced block in Markdown, a component in Solid.

Plain HTML

Load the element's script once, then write the tag. No framework needed.

HTML
<code-playground language="javascript">
console.log("Hello");
</code-playground>
console.log("Hello");

Markdown

With the Astro integration, a fence marked playground becomes the element.

Markdown
Markdown turns a fenced block into a playground:

```python playground
print(sum(n * n for n in range(1, 11) if n % 2))
```

Markdown turns a fenced block into a playground:

print(sum(n * n for n in range(1, 11) if n % 2))

Solid

The Solid front end exports a component; this one is an island of this page.

Solid component
// The smallest Solid use: one playground component with a language and code.
import { Playground } from "code-playgrounds/solid";

export default function SolidExample() {
  return (
    <Playground
      language="lua"
      code={'for i = 1, 3 do print(string.rep("*", i)) end\n'}
      label="Solid example"
    />
  );
}
This example needs JavaScript.