pretext

Compute text height and line geometry in pure JavaScript without DOM reads.

Updated Mar 2, 2026
One-click install
npx skills add https://github.com/goddard-ai/goddard --skill pretext-goddard-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pretext
Source: https://github.com/goddard-ai/goddard/tree/main/app/.agents/skills/pretext
Command: npx skills add https://github.com/goddard-ai/goddard --skill pretext-goddard-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Build, refactor, debug, and review browser UI code that uses Pretext for DOM-free multiline text measurement and manual text layout via prepare, layout, prepareWithSegments, layoutWithLines, walkLineRanges, layoutNextLine, clearCache, or setLocale. Use when Codex must predict text height without DOM reads, preserve line count while shrinkwrapping, route text around shapes or varying-width slots, hand text across columns, or compose measured inline fragments in JS/TS.

Core Features & Use Cases

  • DOM-free measurement APIs: prepare, layout, and the manual-line tools to compute heights, widths, and line fragments without DOM reads.
  • Shape- and column-aware layouts: route text around obstacles and across columns with precise control over line breaks.
  • Caching and locale support: shared caches with setLocale and clearCache to optimize repeated measurements.

Quick Start

Call prepare(text, font) to analyze text, then layout(prepared, maxWidth, lineHeight) to obtain height or lines.

Frequently Asked Questions about pretext

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

FAQPage Schema
How do I measure text height in JavaScript without reading from the DOM?

DOM-free text measurement is achieved by calling prepare(text, font) to analyze the text, then layout(prepared, maxWidth, lineHeight) to compute exact dimensions and line geometry without any DOM reads.

What is the best way to route text around obstacles in a browser UI layout?

Obstacle wrapping is handled by manual text layout tools like layoutWithLines and layoutNextLine, which route inline fragments around shapes and varying-width slots with precise control over line breaks.

How do I flow text across multiple columns in pure JavaScript?

Multi-column flows are computed by passing prepared text through layout APIs, allowing you to hand text across columns and compose measured inline fragments entirely in JS/TS without DOM dependencies.

Can I control locale settings for text measurement and layout operations?

Yes, locale control is supported via the setLocale API, which works alongside shared caches to optimize repeated measurements across different language contexts.

How do I preserve line count while shrinkwrapping text in a UI component?

Use prepareWithSegments to analyze text fragments, then apply layout tools to compute geometry that preserves the original line count while shrinkwrapping the container width.

When should I clear the cache during text layout computations?

Use clearCache when font changes, locale shifts via setLocale, or repeated measurements produce stale geometry, ensuring subsequent layout and prepare calls return fresh line calculations.