LiveEdit-Embeddings for LiaScript: Inline Interactive LiaScript Examples

LiveEdit-Embeddings for LiaScript: Inline Interactive LiaScript Examples

When teaching LiaScript itself — or when building meta-courses that demonstrate LiaScript features — you need a way to show live, editable LiaScript code inline. The LiveEdit-Embeddings template does exactly this: it encodes a LiaScript markdown snippet as a base64 URL and embeds the LiaScript LiveEditor as an inline iframe.

Students see a preview, can switch to edit mode, and can interact with the embedded LiaScript — without navigating away.


Quick Start

<!--
import: https://raw.githubusercontent.com/LiaTemplates/LiveEdit-Embeddings/refs/heads/main/README.md
-->

Macros Overview

All macros are placed in the header of a code block containing LiaScript markdown. The content of the block is the LiaScript source to embed.

MacroView on loadSize
@embedDefault toggle80vh
@embed.editEdit mode first80vh
@embed.previewPreview mode first80vh
@embed.style(style)Default toggleCustom
@embed.edit.style(style)Edit mode firstCustom
@embed.preview.style(style)Preview mode firstCustom

Macro 1: @embed — Default (Toggle View)

The iframe opens with the default LiveEditor toggle between edit and preview.

```markdown @embed
# Hello World

This is a LiaScript example embedded inline.

> **Note:** You can edit this!
```

Macro 2: @embed.preview — Start in Preview Mode

The iframe starts in rendered preview mode. Students see the formatted output immediately and can switch to edit if they want.

```markdown @embed.preview
# A Simple Quiz

What is 2 + 2?

[[4]]
```

Macro 3: @embed.edit — Start in Edit Mode

The iframe opens showing the source code editor. Useful when the goal is for students to modify the code.

```markdown @embed.edit
# Edit me!

Change this text and see the result in preview.
```

Macro 4: @embed.style(style) — Custom Size

Override the iframe dimensions and styling:

```markdown @embed.style("height: 400px; width: 100%; border: 1px solid #ccc;")
# Compact Example

A smaller embedded view.
```

Example: Teaching LiaScript Quizzes

## How to Write a Quiz in LiaScript

Here's a live editable example — try changing the correct answer:

```markdown @embed.preview
# Quiz Demo

What is the capital of France?

[[ Paris | London | Berlin | Madrid ]]
[[ (Paris) | London | Berlin | Madrid ]]
```

Try it live — edit the LiaScript source and switch between edit and preview:


How It Works

  1. The macro takes the content of the code block
  2. Encodes it as base64
  3. Constructs a LiaScript LiveEditor URL with the encoded content
  4. Renders the URL as an iframe srcdoc

No server round-trip is involved. The embedded course is self-contained in the URL.


Full Template Demo


Use Cases

LiaScript documentation and tutorials — Teach LiaScript features with live inline examples that readers can edit directly.

Course authoring workshops — Show participants how to write quizzes, code blocks, and animations, with immediate live preview beside the explanation.

Developer onboarding — Embed runnable LiaScript snippets in technical documentation.

Sandbox exercises — Provide pre-built code templates for students to modify — they edit the LiaScript markdown and see the rendered result in real time.

Interactive OER authoring — Create OER content about OER authoring, with self-referential live examples.


Technical Facts

Runs in browserYes — iframe with base64 LiveEditor URL
Server requiredNo
Content formatLiaScript Markdown
Start in previewYes — @embed.preview
Start in editYes — @embed.edit
Custom sizeYes — @embed.style(...)
LicenseMIT
MaintainedVersion 0.0.1

Try It

Try in LiaScript Open in LiveEditor View on GitHub

Related Posts

PouchDB for LiaScript: NoSQL Documents and Mango Queries in the Browser

Use the PouchDB template to teach NoSQL document databases, Mango queries, and real-time data changes — entirely in the browser, with no server needed.

Read More

Comunica for LiaScript: Run SPARQL Queries and Explore Knowledge Graphs

Use the Comunica template to write and execute SPARQL queries against live knowledge graphs and custom RDF datasets — directly in your LiaScript course, with no server needed.

Read More

A-Frame for LiaScript: 3D and VR Scenes in Your Course

Embed interactive 3D scenes and VR environments in LiaScript using the A-Frame template — write HTML A-Frame markup in a code block and render a fully interactive WebGL scene on any page.

Read More