pretext

Generates single-file HTML demos using @chenglou/pretext for DOM-free text layout and kinetic typography.

Updated Sep 9, 2026
One-click install
npx skills add https://github.com/luckybbjason1/trading --skill pretext-luckybbjason1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pretext
Source: https://github.com/luckybbjason1/trading/tree/main/.hermes/skills/creative/pretext
Command: npx skills add https://github.com/luckybbjason1/trading --skill pretext-luckybbjason1

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @chenglou/pretext, and includes references (resource) components.

What problem does it solve? Building creative browser demos with text that flows around moving shapes, shatters into particles, or forms game geometry requires knowing line breaks before rendering, which CSS cannot provide. This Skill produces polished single-file HTML demos using @chenglou/pretext's canvas-based text measurement. ## Core Features & Use Cases - Text reflow around obstacles: Stream paragraphs around draggable sprites or ASCII logos using layoutNextLineRange with per-row width functions. - Text-as-geometry games and kinetic typography: Build Breakout-style word bricks, shattering glyph particles, and animated editorial layouts with per-line transforms. - Ready-made templates and patterns: Start from hello-orb-flow.html or the advanced donut-orbit.html template, plus a patterns reference covering seven demo archetypes. - Use Case: A user asks for a demo where a paragraph parts around a draggable glowing orb; the Skill generates a self-contained HTML file with pinned esm.sh imports, real prose, a dark palette, and 60fps animation. ## Quick Start Ask the agent to create a pretext demo where text flows around a moving shape, then open the generated HTML file with python3 -m http.server.

Frequently Asked Questions about pretext

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make text flow around a moving shape in the browser?

Use pretext's layoutNextLineRange with a per-row width function that returns the corridor width at each y position. Call prepareWithSegments once, then stream lines each frame, skipping rows where the corridor is too narrow.

What is @chenglou/pretext used for?

Pretext is a 15KB zero-dependency TypeScript library for DOM-free multiline text measurement. Given text, font, and width, it returns line breaks, per-line widths, and grapheme positions via canvas measurement, enabling text-as-geometry demos and games.

How do I import @chenglou/pretext in a browser HTML file?

Import from https://esm.sh/@chenglou/[email protected] inside a script type="module" tag. Use esm.sh rather than unpkg because unpkg serves raw TypeScript that browsers cannot execute.

Why do pretext measurements not match my rendered text?

Measurement drift happens when the canvas ctx.font string differs from the rendered CSS font, often because a web font failed to load and CSS fell back to another family. Preload the font and keep both font strings exactly in sync.

When should I not use pretext for text layout?

Avoid pretext for static pages where CSS already handles layout, rich text editors, and image-to-ASCII conversion. It is intentionally narrow: measurement and line layout only, with no inline formatting engine.