pretext
Ce qu’il fait
Elle aide à construire des démonstrations créatives dans le navigateur où le texte est l'élément visuel principal, comme des paragraphes qui s'écoulent autour d'un sprite en mouvement. Elle s'adresse aux développeurs et designers qui veulent des effets web originaux et saisissants.
Quand l’utiliser
- ✓Quand vous voulez un texte qui s'écoule autour d'une forme ou d'un élément animé en mouvement.
- ✓Quand vous voulez un jeu ou un effet de style ASCII construit à partir de vrais mots.
- ✓Quand vous voulez une typographie cinétique qui brise le texte en particules.
Lien du skill
https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/creative/pretext/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Fais une démonstration dans le navigateur où un paragraphe se réorganise autour d'une balle qui rebondit sur la page.”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
L'agent utilise la bibliothèque pretext pour mesurer et disposer le texte sans passer par l'étape de mise en page habituelle du navigateur, de sorte que les positions se mettent à jour rapidement à chaque image. Il construit ensuite l'effet visuel autour de cette disposition.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis GitHub.
Pretext Creative Demos
Overview
@chenglou/pretext is a 15KB zero-dependency TypeScript library by Cheng Lou (React core, ReasonML, Midjourney) for DOM-free multiline text measurement and layout. It does one thing: given (text, font, width), return the line breaks, per-line widths, per-grapheme positions, and total height — all via canvas measurement, no reflow.
That sounds like plumbing. It is not. Because it is fast and geometric, it is a creative primitive: you can reflow paragraphs around a moving sprite at 60fps, build games whose level geometry is made of real words, drive ASCII logos through prose, shatter text into particles with exact per-grapheme starting positions, or pack shrink-wrapped multiline UI without any getBoundingClientRect thrash.
This skill exists so Hermes can make cool demos with it — the kind people post to X. See pretext.cool and chenglou.me/pretext for the community demo corpus.
When to Use
Use when the user asks for:
- A "pretext demo" / "cool pretext thing" / "text-as-X"
- Text flowing around a moving shape (hero sections, editorial layouts, animated long-form pages)
- ASCII-art effects using real words or prose, not monospace rasters
- Games where the playfield / obstacles / bricks are made of text (Tetris-from-letters, Breakout-of-prose)
- Kinetic typography with per-glyph physics (shatter, scatter, flock, flow)
- Typographic generative art, especially with non-Latin scripts or mixed scripts
- Multiline "shrink-wrap" UI (smallest container width that still fits the text)
- Anything that would require knowing line breaks before rendering
Don't use for:
- Static SVG/HTML pages where CSS already solves layout — just use CSS
- Rich text editors, general inline formatting engines (pretext is intentionally narrow)
- Image → text (use
ascii-art/ascii-videoskills) - Pure canvas generative art with no text role — use
p5js
Creative Standard
This is visual art rendered in a browser. Pretext returns numbers; you draw the thing.
- Don't ship a "hello world" demo. The
hello-orb-flow.htmltemplate is the starting point. Every delivered demo must add intentional color, motion, composition, and one visual detail the user didn't ask for but will appreciate. - Dark backgrounds, warm cores, considered palette. Classic amber-on-black (CRT / terminal) works, but so do cold-white-on-charcoal (editorial) and desaturated pastels (risograph). Pick one and commit.
- Proportional fonts are the point. Pretext's whole vibe is "not monospaced" — lean into it. Use Iowan Old Style, Inter, JetBrains Mono, Helvetica Neue, or a variable font. Never default sans.
- Real source/text, not lorem ipsum. The corpus should mean something. Short manifestos, poetry, real source code, a found text, the library's own README — never
lorem ipsum. - First-paint excellence. No loading states, no blank frames. The demo must look shippable the instant it opens.
Stack
Single self-contained HTML file per demo. No build step.
| Layer | Tool | Purpose |
|---|---|---|
| Core | @chenglou/pretext via esm.sh CDN |
Text measurement + line layout |
| Render | HTML5 Canvas 2D | Glyph rendering, per-frame composition |
| Segmentation | Intl.Segmenter (built-in) |
Grapheme splitting for emoji / CJK / combining marks |
| Interaction | Raw DOM events | Mouse / touch / wheel — no framework |
<script type="module">
import {
prepare, layout, // use-case 1: simple height
prepareWithSegments, layoutWithLines, // use-case 2a: fixed-width lines
layoutNextLineRange, materializeLineRange, // use-case 2b: streaming / variable width
measureLineStats, walkLineRanges, // stats without string allocation
} from "https://esm.sh/@chenglou/pretext@0.0.6";
</script>
Pin the version. @0.0.6 at time of writing — check npm for the latest if demo behavior is off.
The Two Use Cases
Almost everything reduces to one of these two shapes. Learn both.
Use-case 1 — measure, then render with CSS/DOM
const prepared = prepare(text, "16px Inter");
const { height, lineCount } = layout(prepared, 320, 20);
You still let the browser draw the text. Pretext just tells you how tall the box will be at a given width, without a DOM read. Use for:
- Virtualized lists where rows contain wrapping text
- Masonry with precise card he
Questions fréquentes
Qu'est-ce que la bibliothèque pretext ?
Une petite bibliothèque TypeScript qui mesure et dispose du texte sur plusieurs lignes sans toucher à la mise en page de la page.
Est-ce destiné aux sites de production ?
La skill vise les démonstrations créatives, du type de celles que l'on partage en ligne, plutôt que la mise en page quotidienne des pages.
Quelle est la taille de la bibliothèque ?
La skill la décrit comme environ 15 Ko, sans dépendances.
Détails
Description originale de l’auteur
Build creative browser demos with DOM-free text layout.
Popularité
- Étoiles GitHub
- 260k
- Position au classement
- #474
- Licence
- MIT
- Mis à jour
- 02/11/2026
Commentaires
- …
Autres skills de ce dépôt
agent-merge-conflict-arbiter
260kRègle un conflit de fusion git entre les branches de deux agents, en tant que tiers neutre, et produit un seul résultat fusionné pour le dépôt.
antigravity-cli
260kVous guide dans l'installation, la mise à jour et le dépannage de l'outil en ligne de commande Antigravity, y compris ses extensions, sa connexion et son bac à sable.
blackbox
260kPermet à votre agent de confier une tâche de programmation à l'outil en ligne de commande Blackbox AI, qui fait tourner plusieurs modèles d'IA et retient le meilleur résultat.
dynamic-workflow
260kApprend à votre agent à exécuter de gros lots de travaux similaires sous forme de script enregistré, afin que seuls les résultats vérifiés remontent dans la conversation principale.
Skills similaires
angular-developer
280kAide votre agent à créer du code Angular et à conseiller sur la structure des projets. Utile pour démarrer, créer des composants ou améliorer performances et accessibilité.
frontend-a11y
280kAide votre agent à rendre les interfaces web accessibles à tous. Il garantit que sites et apps fonctionnent avec les lecteurs d'écran et la navigation au clavier.
frontend-patterns
280kPermet à votre agent d'appliquer les modèles modernes du frontend : optimisation des performances, gestion d'état et bonnes pratiques avec React et Next.js.