pretext
यह क्या करती है
यह रचनात्मक ब्राउज़र डेमो बनाने में मदद करती है, जहां टेक्स्ट मुख्य विज़ुअल तत्व है, जैसे चलते स्प्राइट के चारों ओर बहते अनुच्छेद। यह उन डेवलपर्स और डिज़ाइनरों के लिए है जिन्हें अनोखे, आकर्षक वेब प्रभाव चाहिए।
कब इस्तेमाल करें
- ✓जब आप चाहते हों कि टेक्स्ट चलती आकृति या एनिमेटेड तत्व के चारों ओर बहे।
- ✓जब आप असली शब्दों से बना गेम या ASCII-शैली का प्रभाव चाहते हों।
- ✓जब आप ऐसी गतिशील टाइपोग्राफ़ी चाहते हों जो टेक्स्ट को कणों में बदल दे।
Skill का लिंक
https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/creative/pretext/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“ऐसा ब्राउज़र डेमो बनाइए जहां एक अनुच्छेद पेज पर उछलती गेंद के चारों ओर पुनर्व्यवस्थित हो।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट pretext लाइब्रेरी इस्तेमाल करता है, जो ब्राउज़र के सामान्य layout चरण के बिना टेक्स्ट को मापती और व्यवस्थित करती है, ताकि हर फ़्रेम पर स्थितियां तेज़ी से अपडेट हो सकें। फिर वह उस लेआउट के आसपास विज़ुअल प्रभाव बनाता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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
अक्सर पूछे जाने वाले सवाल
pretext लाइब्रेरी क्या है?
एक छोटी TypeScript लाइब्रेरी जो पेज के layout को छुए बिना बहु-पंक्ति टेक्स्ट को मापती और व्यवस्थित करती है।
क्या यह प्रोडक्शन वेबसाइटों के लिए है?
स्किल रचनात्मक डेमो के लिए है, जिन्हें लोग ऑनलाइन साझा करते हैं, न कि रोज़मर्रा के पेज layout के लिए।
लाइब्रेरी कितनी बड़ी है?
स्किल इसे बिना निर्भरता वाली लगभग 15KB बताती है।
जानकारी
लेखक का मूल विवरण
Build creative browser demos with DOM-free text layout.
लोकप्रियता
- GitHub स्टार
- 260k
- रैंकिंग में स्थान
- #474
- लाइसेंस
- MIT
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
agent-merge-conflict-arbiter
260kदो एजेंट्स की branches के बीच git merge conflict को एक निष्पक्ष तीसरे पक्ष के रूप में सुलझाती है और रिपॉज़िटरी के लिए एक merged नतीजा बनाती है।
antigravity-cli
260kAntigravity कमांड-लाइन टूल को इंस्टॉल करने, अपडेट करने और उसकी दिक्कतें सुलझाने में मार्गदर्शन देती है, जिसमें प्लगइन, साइन-इन और sandbox शामिल हैं।
blackbox
260kआपके एजेंट को कोडिंग काम Blackbox AI कमांड-लाइन टूल को सौंपने देती है, जो कई AI मॉडल चलाकर सबसे अच्छा नतीजा चुनता है।
dynamic-workflow
260kआपके एजेंट को बड़े बैच के एक जैसे कामों को सेव की गई स्क्रिप्ट के रूप में चलाना सिखाती है, ताकि मुख्य बातचीत में केवल जांचे गए नतीजे लौटें।
मिलती-जुलती skills
angular-developer
280kआपके एजेंट को Angular code बनाने और प्रोजेक्ट स्ट्रक्चर पर सलाह देने में मदद करता है। नए प्रोजेक्ट शुरू करने, code के हिस्से बनाने, या performance और accessibility सुधारने में उपयोगी है।
frontend-a11y
280kआपके एजेंट को web interfaces को सबके लिए accessible बनाने में मदद करता है। यह सुनिश्चित करता है कि websites और apps screen readers और keyboard navigation के साथ अच्छे से काम करें।
frontend-patterns
280kआपके एजेंट को React और Next.js में frontend development के modern patterns लागू करने में मदद करता है। यह performance optimize करता है, state manage करता है और best practices फॉलो करवाता है।