TurboWarp HTML

TurboWarp HTML builds HTML as immutable structured fragments. Blocks create escaped text, elements, attributes, and sibling sequences; the final HTML string is produced only by an explicit render block.

Core Flow

text [Server status]
h1 [text result]
body [h1 result]
html [body result]
render HTML [html result]

Safety Model

Common Blocks

CategoryBlocks
Contenttext, concat, render, renderWithValidation
Documenthtml, head, body, title
CSSstyle, normally placed inside head
Text structureh1 through h6, p, div, span
Links and medialink, externalLink, image, turbowarpProjectFrame, scratchProjectFrame, packagedProjectFrame
Lists and tablesul, ol, li, table, tr, th, td
Formsform, label, input, textarea, select, option, button

HTTP Server Interoperability

For turbowarp-http-server, pass the rendered string as the response body and set Content-Type: text/html; charset=utf-8. The HTTP server does not need to depend on this package.

Educational CSS

Use class attributes on elements and define those classes with style [CSS] in head. CSS is useful for teaching presentation and layout, but it can also visually hide or imitate UI, so load projects only from trusted sources.

TypeScript API

The package also exports block-free builder functions from @kubohiroya/turbowarp-html, including text, element, common element factories, externalLink, turbowarpProjectFrame, scratchProjectFrame, packagedProjectFrame, withAttribute, concat, render, renderWithValidation, and validate.

TurboWarp HTML: complete block reference

All 44 blocks are documented below, including compatibility blocks and blocks available through optional features. Select a block to read its behavior, arguments, default values, and menu choices. Each block has a permanent link.

text [TEXT]

Creates an escaped HTML text fragment.

Block type: REPORTER. Opcode: text. Permanent link

ArgumentTypeDefault valueMenu choices
TEXTSTRINGHello <world>

element [TAG] content [CONTENT]

Creates a valid HTML element with escaped structured content.

Block type: REPORTER. Opcode: element. Permanent link

ArgumentTypeDefault valueMenu choices
TAGSTRINGsection
CONTENTSTRING

[ELEMENT] with attribute [NAME] = [VALUE]

Returns a new element with a safe escaped attribute value.

Block type: REPORTER. Opcode: withAttribute. Permanent link

ArgumentTypeDefault valueMenu choices
ELEMENTSTRING
NAMESTRINGclass
VALUESTRINGcard

[LEFT] followed by [RIGHT]

Creates a fragment sequence from two HTML fragments.

Block type: REPORTER. Opcode: concat. Permanent link

ArgumentTypeDefault valueMenu choices
LEFTSTRING
RIGHTSTRING

render HTML [FRAGMENT]

Renders an HTML fragment to final HTML text without updating stored validation errors.

Block type: REPORTER. Opcode: render. Permanent link

ArgumentTypeDefault valueMenu choices
FRAGMENTSTRING

render HTML with validation [FRAGMENT]

Validates an HTML fragment, stores any validation errors, and renders final HTML text.

Block type: REPORTER. Opcode: renderWithValidation. Permanent link

ArgumentTypeDefault valueMenu choices
FRAGMENTSTRING

last HTML validation errors

Returns validation errors stored by the most recent render HTML block.

Block type: REPORTER. Opcode: lastValidationErrors. Permanent link

This block has no arguments.

last rendered HTML has validation errors?

Reports whether the most recent render HTML block stored validation errors.

Block type: BOOLEAN. Opcode: lastRenderHasValidationErrors. Permanent link

This block has no arguments.

validate HTML [FRAGMENT]

Returns simple validation diagnostics for an HTML fragment.

Block type: REPORTER. Opcode: validateHtml. Permanent link

ArgumentTypeDefault valueMenu choices
FRAGMENTSTRING

HTML [FRAGMENT] is valid?

Reports whether simple validation found no HTML errors.

Block type: BOOLEAN. Opcode: isValidHtml. Permanent link

ArgumentTypeDefault valueMenu choices
FRAGMENTSTRING

link [CONTENT] URL [URL]

Creates an anchor with a conservatively validated URL.

Block type: REPORTER. Opcode: link. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGTurboWarp
URLSTRINGhttps://turbowarp.org/

external link [CONTENT] URL [URL]

Creates an anchor that opens in a new tab with safe rel attributes.

Block type: REPORTER. Opcode: externalLink. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGTurboWarp
URLSTRINGhttps://turbowarp.org/

image URL [SRC] alt [ALT]

Creates a void image element with safe src and escaped alt text.

Block type: REPORTER. Opcode: image. Permanent link

ArgumentTypeDefault valueMenu choices
SRCSTRING/status.png
ALTSTRINGstatus

TurboWarp project [PROJECT_ID] iframe title [TITLE] width [WIDTH] height [HEIGHT]

Creates a safe iframe for playing a TurboWarp project.

Block type: REPORTER. Opcode: turbowarpProjectFrame. Permanent link

ArgumentTypeDefault valueMenu choices
PROJECT_IDSTRING414716080
TITLESTRINGTurboWarp project
WIDTHSTRING482
HEIGHTSTRING412

Scratch project [PROJECT_ID] iframe title [TITLE] width [WIDTH] height [HEIGHT]

Creates a safe iframe for playing a Scratch project.

Block type: REPORTER. Opcode: scratchProjectFrame. Permanent link

ArgumentTypeDefault valueMenu choices
PROJECT_IDSTRING104
TITLESTRINGScratch project
WIDTHSTRING485
HEIGHTSTRING402

packaged TurboWarp project iframe URL [SRC] title [TITLE] width [WIDTH] height [HEIGHT]

Creates a safe iframe for playing a same-site TurboWarp Packager HTML file.

Block type: REPORTER. Opcode: packagedProjectFrame. Permanent link

ArgumentTypeDefault valueMenu choices
SRCSTRING./project.html
TITLESTRINGPackaged TurboWarp project
WIDTHSTRING480
HEIGHTSTRING360

html [CONTENT]

Creates an html element.

Block type: REPORTER. Opcode: html. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

head [CONTENT]

Creates a head element.

Block type: REPORTER. Opcode: head. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

body [CONTENT]

Creates a body element.

Block type: REPORTER. Opcode: body. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

title [CONTENT]

Creates a title element.

Block type: REPORTER. Opcode: title. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGStatus

style [CSS]

Creates a style element for educational CSS.

Block type: REPORTER. Opcode: style. Permanent link

ArgumentTypeDefault valueMenu choices
CSSSTRING.card { color: red; }

h1 [CONTENT]

Creates an h1 element.

Block type: REPORTER. Opcode: h1. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGServer status

h2 [CONTENT]

Creates an h2 element.

Block type: REPORTER. Opcode: h2. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGHeading

h3 [CONTENT]

Creates an h3 element.

Block type: REPORTER. Opcode: h3. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGHeading

h4 [CONTENT]

Creates an h4 element.

Block type: REPORTER. Opcode: h4. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGHeading

h5 [CONTENT]

Creates an h5 element.

Block type: REPORTER. Opcode: h5. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGHeading

h6 [CONTENT]

Creates an h6 element.

Block type: REPORTER. Opcode: h6. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGHeading

p [CONTENT]

Creates a paragraph element.

Block type: REPORTER. Opcode: p. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGReady

div [CONTENT]

Creates a div element.

Block type: REPORTER. Opcode: div. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

span [CONTENT]

Creates a span element.

Block type: REPORTER. Opcode: span. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

ul [CONTENT]

Creates an unordered list element.

Block type: REPORTER. Opcode: ul. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

ol [CONTENT]

Creates an ordered list element.

Block type: REPORTER. Opcode: ol. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

li [CONTENT]

Creates a list item element.

Block type: REPORTER. Opcode: li. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGitem

table [CONTENT]

Creates a table element.

Block type: REPORTER. Opcode: table. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

tr [CONTENT]

Creates a table row element.

Block type: REPORTER. Opcode: tr. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

th [CONTENT]

Creates a table header cell element.

Block type: REPORTER. Opcode: th. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGName

td [CONTENT]

Creates a table data cell element.

Block type: REPORTER. Opcode: td. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGValue

form [CONTENT]

Creates a form element.

Block type: REPORTER. Opcode: form. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

label [CONTENT]

Creates a label element.

Block type: REPORTER. Opcode: label. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGName

input

Creates a void input element.

Block type: REPORTER. Opcode: input. Permanent link

This block has no arguments.

textarea [CONTENT]

Creates a textarea element.

Block type: REPORTER. Opcode: textarea. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

select [CONTENT]

Creates a select element.

Block type: REPORTER. Opcode: select. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRING

option [CONTENT]

Creates an option element.

Block type: REPORTER. Opcode: option. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGChoice

button [CONTENT]

Creates a button element.

Block type: REPORTER. Opcode: button. Permanent link

ArgumentTypeDefault valueMenu choices
CONTENTSTRINGSubmit

Repository guide and examples