1Password에 저장한 비밀번호와 API 키를 명령과 설정 템플릿에 사용합니다. CLI 설치와 인증부터 비밀 값 조회 및 환경 변수 전달까지 안내합니다.
- 1Password CLI 설치와 설정
- 저장된 API 키로 명령 실행
- 설정 템플릿에 비밀 값 삽입
글자 위치를 미리 계산해 움직이는 도형을 피하는 문장, 클릭하면 흩어지는 글자, 단어 게임과 여러 줄 글에 맞는 카드를 단일 HTML로 만듭니다.
Build creative browser demos with DOM-free text layout.
pretext는 글자를 활용한 동적인 브라우저 데모를 만듭니다. @chenglou/pretext로 줄바꿈 위치, 줄 너비, 글자별 좌표를 그리기 전에 계산합니다. 이를 활용해 움직이는 도형을 피해 흐르는 문장이나 클릭하면 글자가 흩어지는 효과를 만듭니다. 단어를 블록으로 쓰는 게임과 여러 줄의 글에 꼭 맞는 카드도 다룹니다. 기본 구성은 Canvas 2D와 단일 HTML 파일이며 빌드 작업은 필요하지 않습니다.
웹페이지에 글 자체를 활용한 시각 효과를 더하거나 사용자 조작에 반응하는 타이포그래피를 실험할 때 적합합니다. 제공되는 템플릿에서 시작해 글 내용, 서체, 색상, 움직임과 조작 방식을 구체화합니다.
라이브러리는 esm.sh를 통해 불러옵니다. 측정할 때와 그릴 때의 글꼴 설정을 일치시켜야 합니다. 일반적인 정적 레이아웃이나 범용 서식 있는 텍스트 편집에는 적합하지 않습니다. 스킬의 라이선스는 MIT입니다.
이 소개문은 공개된 SKILL.md를 바탕으로 AI(OpenAI Codex)가 작성했습니다. 정확한 사양은 아래 원문을 확인하세요.
AI가 SKILL.md의 내용만을 근거로 4가지 관점에서 판정했습니다. 스타 수나 인기도는 판정에 넣지 않았습니다.
총점은 각 항목을 A=25점, B=15점, C=5점으로 더한 값입니다. 2026년 10월 20일 기준으로 AI(OpenAI Codex)가 판정했습니다. 참고용이므로 설치 전에 원문도 확인해 주세요.
설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.
@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.
Use when the user asks for:
Don't use for:
ascii-art / ascii-video skills)p5jsThis is visual art rendered in a browser. Pretext returns numbers; you draw the thing.
hello-orb-flow.html template 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.lorem ipsum.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.
Almost everything reduces to one of these two shapes. Learn both.
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:
Keep font and letterSpacing exactly in sync with your CSS. The canvas ctx.font format (e.g. "16px Inter", "500 17px 'JetBrains Mono'") must match the rendered CSS, or measurements drift.
const prepared = prepareWithSegments(text, FONT);
const { lines } = layoutWithLines(prepared, 320, 26);
for (let i = 0; i < lines.length; i++) {
ctx.fillText(lines[i].text, 0, i * 26);
}
This is where the creative work lives. You own the drawing, so you can:
For variable-width-per-line flow (text around a shape, text in a donut band, text in a non-rectangular column):
let cursor = { segmentIndex: 0, graphemeIndex: 0 };
let y = 0;
while (true) {
const lineWidth = widthAtY(y); // your function: how wide is the corridor at this y?
const range = layoutNextLineRange(prepared, cursor, lineWidth);
if (!range) break;
const line = materializeLineRange(prepared, range);
ctx.fillText(line.text, leftEdgeAtY(y), y);
cursor = range.end;
y += lineHeight;
}
This is the most important pattern in the whole library. It's what unlocks "text flowing around a dragged sprite" — the demo that went viral on X.
measureLineStats(prepared, maxWidth) → { lineCount, maxLineWidth } — the widest line, i.e. multiline shrink-wrap width.walkLineRanges(prepared, maxWidth, callback) — iterate lines without allocating strings. Use for stats/physics over graphemes when you don't need the characters.@chenglou/pretext/rich-inline — the same system but for paragraphs mixing fonts / chips / mentions. Import from the subpath.The community corpus (see references/patterns.md) clusters into a handful of strong patterns. Pick one and riff — don't invent a new category unless asked.
| Pattern | Key API | Example idea |
|---|---|---|
| Reflow around obstacle | layoutNextLineRange + per-row width function | Editorial paragraph that parts around a dragged cursor sprite |
| Text-as-geometry game | layoutWithLines + per-line collision rects | Breakout where each brick is a measured word |
| Shatter / particles | walkLineRanges → per-grapheme (x,y) → physics | Sentence that explodes into letters on click |
| ASCII obstacle typography | layoutNextLineRange + measured per-row obstacle spans | Bitmap ASCII logo, shape morphs, and draggable wire objects that make text open around their actual geometry |
| Editorial multi-column | layoutNextLineRange per column + shared cursor | Animated magazine spread with pull quotes |
| Kinetic type | layoutWithLines + per-line transform over time | Star Wars crawl, wave, bounce, glitch |
| Multiline shrink-wrap | measureLineStats | Quote card that auto-sizes to its tightest container |
See templates/donut-orbit.html and templates/hello-orb-flow.html for working single-file starters.
templates/hello-orb-flow.html — text reflowing around a moving orb (reflow-around-obstacle pattern)templates/donut-orbit.html — advanced example: measured ASCII logo obstacles, draggable wire sphere/cube, morphing shape fields, selectable DOM text, and dev-only controlswrite_file to a new .html in ~/.hermes/cache/scratch/ or the user's workspace.cd <dir-with-html> && python -m http.server 8765
# then open http://localhost:8765/<file>.html
prepareWithSegments is called with a bad font string; Intl.Segmenter is available in every modern browser.prepare() / prepareWithSegments() is the expensive call. Do it once per text+font pair. Cache the handle.layout() / layoutWithLines() — never re-prepare.layoutNextLineRange in a tight loop is cheap enough to do every frame at 60fps for normal-length paragraphs.Uint8Array/typed arrays), derive measured per-row obstacle spans from the cells or projected geometry, merge spans, then feed those spans into layoutNextLineRange before drawing text.ctx.font setting is surprisingly slow; set it once per frame if font doesn't vary, not per fillText call.Drifting CSS/canvas font strings. ctx.font = "16px Inter" measured, but CSS says font-family: Inter, sans-serif; font-size: 16px. Fine if Inter loads. If Inter 404s, CSS falls back to sans-serif and measurements drift by 5-20%. Always preload the font or use a web-safe family.
Re-preparing inside the animation loop. Only layout* is cheap. Re-calling prepare every frame will tank perf. Keep the prepared handle in module scope.
Forgetting Intl.Segmenter for grapheme splits. Emoji, combining marks, CJK — "é".split("") gives you two chars. Use new Intl.Segmenter(undefined, { granularity: "grapheme" }) when sampling individual visible glyphs.
break: 'never' chips without extraWidth. In rich-inline, if you use break: 'never' for an atomic chip/mention, you must also supply extraWidth for the pill padding — otherwise chip chrome overflows the container.
Using @chenglou/pretext from unpkg with TypeScript-only entry. Use esm.sh — it compiles the TS exports to browser-ready ESM automatically. unpkg will 404 or serve raw TS.
Monospace fallbacks silently erasing the whole point. Users seeing monospace-looking output often have a CSS font-family that fell through to monospace. Verify the actual rendered font via DevTools.
Skipping rows vs adjusting width when flowing around a shape. If the corridor on this row is too narrow to fit a line, skip the row (y += lineHeight; continue;) rather than passing a tiny maxWidth to layoutNextLineRange — pretext will return one-grapheme lines that look broken.
Shipping a cold demo. The default first-paint looks tutorial-grade. Add: vignette, subtle scanline, idle auto-motion, one carefully chosen interactive response (drag, hover, scroll, click). Without these, "cool pretext demo" lands as "intern repro of the README."
.html file — opens by double-click or python -m http.server@chenglou/pretext imported via esm.sh with pinned versionprepare matches the CSS font exactlyprepare() / prepareWithSegments() called once, not per framepython -m http.server and confirmed no console errorsClone these for inspiration / patterns (all MIT-ish, linked from pretext.cool):
github.com/rinesh/pretext-breakergithub.com/shinichimochizuki/tetris-pretextgithub.com/qtakmalay/PreTextExperimentsgithub.com/somnai-dreams/pretext-demosgithub.com/frmlinn/bad-apple-pretextgithub.com/dokobot/pretext-demogithub.com/SmisLee/alarmy-pretext-demoOfficial playground: chenglou.me/pretext — accordion, bubbles, dynamic-layout, editorial-engine, justification-comparison, masonry, markdown-chat, rich-note.
아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.
로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.
아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.
1Password에 저장한 비밀번호와 API 키를 명령과 설정 템플릿에 사용합니다. CLI 설치와 인증부터 비밀 값 조회 및 환경 변수 전달까지 안내합니다.
손익계산서·재무상태표·현금흐름표를 수식으로 연결한 Excel 모델을 만듭니다. 실적과 예측 가정을 입력하고 시나리오를 비교하며 세 재무제표의 일관성을 단계별로 확인합니다.
기존 PyTorch 학습 코드를 적은 수정으로 여러 GPU나 컴퓨터에 맞게 구성합니다. 혼합 정밀도, 메모리 절약 설정과 학습 실행 방법을 안내합니다.
Hermes에서 Actual Computer로 자신의 기기에 AI 모델을 실행하도록 연결을 설정합니다. 중계 서비스와 로컬 연결, 모델 선택, 응답 확인 및 오류 점검을 다룹니다.
기술에 익숙하지 않고 쉽게 불만을 느끼는 사용자로 앱을 시험합니다. 혼란스러운 조작과 이탈 원인을 찾고, 개선 과제와 개인적 불만을 나눠 수정안을 정리합니다.
두 에이전트가 각각 수정한 브랜치의 Git 충돌을 양쪽 변경 내용과 의도에 따라 중립적으로 해결합니다. 충돌별 판단 이유를 기록하고 빌드나 테스트로 통합 결과를 확인합니다.