← Back to Skills Marketplace
132
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install pretext-text-measurement
Description
精准文本测量与布局引擎(基于开源 Pretext)。无需触碰 DOM,纯算术计算文本像素高度,支持中文、CJK、emoji 等多语言。多用于前端虚拟滚动、AI 生成 UI 布局预计算、Canvas 渲染等场景。当用户需要计算文字在指定宽度下的高度、判断换行行数、或精确布局文本时调用此 Skill。
Usage Guidance
This skill appears to do what it claims: Node scripts implement Pretext-based text measurement and require only Node (and optionally node-canvas for higher fidelity). Before installing or running it: 1) Inspect SKILL.md for hidden/unexpected characters (the scanner found unicode control chars). 2) Run install-deps.js (or run npm install manually) inside a sandbox or on a dev machine — it will download @chenglou/pretext and optionally canvas from npm/unpkg. 3) Be aware node-canvas may need system libraries (Cairo/Pango) and npm install will run network requests. 4) If you plan to paste browser snippets produced by measure-browser.js, review those snippets and avoid pasting unknown scripts into production browsers; they load code from unpkg. 5) If you need higher assurance, verify the @chenglou/pretext package/version on npm/GitHub and audit dependencies before use.
Capability Analysis
Type: OpenClaw Skill
Name: pretext-text-measurement
Version: 1.0.1
The skill is a comprehensive text measurement and layout engine based on the open-source @chenglou/pretext library. It provides a suite of Node.js scripts (e.g., measure.js, batch.js, layout-lines.js) designed to calculate text dimensions and line counts without a DOM, which is useful for frontend layout pre-calculation. The bundle includes standard installation logic (install-deps.js) and utility scripts for generating HTML/Canvas snippets (render-dom.js, particle-text.js) that align perfectly with its stated purpose. No evidence of data exfiltration, malicious execution, or harmful prompt injection was found.
Capability Tags
Capability Assessment
Purpose & Capability
Name/description match the delivered artifacts: package.json declares @chenglou/pretext and optional canvas, and the scripts implement measuring, layout, batch, rich-text and canvas helpers. Required binary is only node which is appropriate for a Node.js-based text-measurement skill.
Instruction Scope
SKILL.md instructs the agent to run local node scripts (measure.js, batch.js, layout-lines.js, etc.) and to optionally paste generated snippets into a browser. This is consistent with the stated purpose. Caution: measure-browser.js emits code/snippets that instruct loading pretext from an external CDN (unpkg) intended for browser evaluation — that has the usual risks of executing remotely-hosted JS if pasted into a browser console.
Install Mechanism
There is no platform install spec, but scripts/install-deps.js will execSync npm install to pull @chenglou/pretext and canvas. This is expected for a Node skill, but it downloads packages from npm/unpkg at install/runtime — users should be aware this fetches third-party code and that node-canvas may require system libs. The install uses standard npm commands (no obscure URLs or shorteners).
Credentials
The skill requests no environment variables, no credentials and no config paths. The code only relies on the Node runtime and optional native canvas libs; that is proportionate to the functionality.
Persistence & Privilege
The skill is not always-enabled and does not request elevated or persistent agent/system privileges. It does not modify other skills' configs. Its install helper modifies only files in its own skill directory (npm modules).
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install pretext-text-measurement - After installation, invoke the skill by name or use
/pretext-text-measurement - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
No changes detected in this version (1.0.1).
- No file changes or documentation updates present compared to previous version.
- All features, usage, and guidance remain consistent with the prior release.
Pretext Skill 发布信息
🗂️ ClawHub 填表信息
表单字段 填写内容
Skill 名称 pretext
Slug pretext-text-measurement
版本号 1.0.0
许可证 MIT
作者 QiuZhenPeng
分类 Developer Tools / Frontend / Text Processing
标签(Tags) text-measurement, layout, frontend, virtual-scroll, canvas, chinese-text, i18n, nodejs, ai-ui
Icon / Emoji 📐
GitHub 地址 https://github.com/chenglou/pretext
价格 免费(Free)
是否开源 ✅ 是(基于 MIT)
是否收费 ❌ 否
ClawHub 短简介(≤80 字符)
无需 DOM,纯算术计算任意文字在指定宽度下的像素高度与行数。
支持中文、CJK、emoji,零依赖极速运行。
ClawHub 完整产品简介
## 📐 Pretext — 精准文本测量与布局引擎
> 「不需要 DOM reflow,不需要 setTimeout,不需要把文字渲染出来再量——直接算出来。」
### 这个 Skill 能解决什么问题?
当你开发虚拟滚动列表、聊天应用、AI 生成 UI、Canvas 文本渲染等场景时,必须提前知道每段文字会占据多高。
传统方案要么渲染后量(慢),要么字数估算(不准)。
Pretext 的解法:**提前一次性测量每个字符的宽度,之后纯算术遍历——O(n) 时间,零 DOM 操作,结果与浏览器渲染高度一致。**
### 核心能力
- **计算高度**:输入文本 + 字体 + 宽度 → 输出精确像素高度
- **判断换行**:返回总行数 + 每行具体内容
- **批量测量**:一次测量 1000 条消息(比 DOM 快 300–600 倍)
- **逐行坐标**:输出每行的起止位置(用于 Canvas 绘制)
- **富文本布局**:支持 @提及、代码块、标签等内联样式
- **DOM 渲染片段**:生成可直接粘贴的逐行 HTML,无需触碰真实 DOM
### 支持语言
中文、CJK(中日韩)、emoji、英文等所有 Unicode 文本。
> ⚠️ 暂不支持 RTL 语言(阿拉伯文、希伯来文)。
### 安装要求
- Node.js v16+
- 可选:`npm install canvas` — 安装后精度更高,未安装不影响基础功能
「文件含 emoji(UTF-16 代理对编码),非恶意字符」
v1.0.0
Initial release of the Pretext Text Measurement Skill.
- Provides an accurate, DOM-free text measurement and layout engine powered by @chenglou/pretext.
- Supports measurement of text height and line count for any width, font, and multi-language content including CJK and emoji.
- Enables multiple use cases: virtual scrolling, AI UI layout precomputation, canvas rendering, chat message measurement, and more.
- Includes scripts and API guidelines for batch measurement, per-line layout, rich inline text, particle effects, and DOM rendering.
- Optional high-precision mode available with node-canvas; gracefully degrades to pure JS when not installed.
- Detailed usage documentation and ready-to-use command examples provided.
Pretext Skill 发布信息

🗂️ ClawHub 填表信息
表单字段
填写内容
Skill 名称
pretext
Slug
pretext-text-measurement
版本号
1.0.0
许可证
MIT
作者
QiuZhenPeng
分类
Developer Tools / Frontend / Text Processing
标签(Tags)
text-measurement, layout, frontend, virtual-scroll, canvas, chinese-text, i18n, nodejs, ai-ui
Icon / Emoji
📐
GitHub 地址
https://github.com/chenglou/pretext
价格
免费(Free)
是否开源
✅ 是(基于 MIT)
是否收费
❌ 否
ClawHub 短简介(≤80 字符)
无需 DOM,纯算术计算任意文字在指定宽度下的像素高度与行数。
支持中文、CJK、emoji,零依赖极速运行。
ClawHub 完整产品简介
## 📐 Pretext — 精准文本测量与布局引擎
> 「不需要 DOM reflow,不需要 setTimeout,不需要把文字渲染出来再量——直接算出来。」
### 这个 Skill 能解决什么问题?
当你开发虚拟滚动列表、聊天应用、AI 生成 UI、Canvas 文本渲染等场景时,必须提前知道每段文字会占据多高。
传统方案要么渲染后量(慢),要么字数估算(不准)。
Pretext 的解法:**提前一次性测量每个字符的宽度,之后纯算术遍历——O(n) 时间,零 DOM 操作,结果与浏览器渲染高度一致。**
### 核心能力
- **计算高度**:输入文本 + 字体 + 宽度 → 输出精确像素高度
- **判断换行**:返回总行数 + 每行具体内容
- **批量测量**:一次测量 1000 条消息(比 DOM 快 300–600 倍)
- **逐行坐标**:输出每行的起止位置(用于 Canvas 绘制)
- **富文本布局**:支持 @提及、代码块、标签等内联样式
- **DOM 渲染片段**:生成可直接粘贴的逐行 HTML,无需触碰真实 DOM
### 支持语言
中文、CJK(中日韩)、emoji、英文等所有 Unicode 文本。
> ⚠️ 暂不支持 RTL 语言(阿拉伯文、希伯来文)。
### 安装要求
- Node.js v16+
- 可选:`npm install canvas` — 安装后精度更高,未安装不影响基础功能
Metadata
Frequently Asked Questions
What is pretext?
精准文本测量与布局引擎(基于开源 Pretext)。无需触碰 DOM,纯算术计算文本像素高度,支持中文、CJK、emoji 等多语言。多用于前端虚拟滚动、AI 生成 UI 布局预计算、Canvas 渲染等场景。当用户需要计算文字在指定宽度下的高度、判断换行行数、或精确布局文本时调用此 Skill。 It is an AI Agent Skill for Claude Code / OpenClaw, with 132 downloads so far.
How do I install pretext?
Run "/install pretext-text-measurement" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is pretext free?
Yes, pretext is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does pretext support?
pretext is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created pretext?
It is built and maintained by Freyr (@markcookie); the current version is v1.0.1.
More Skills