@drghaliasri/butex

中文文档
8.1.2发布于 2026/11/14ISCTypeScriptESM + CJS近 30 天下载 2092

MathJax extension layer for Arabic-friendly math notation (XeLaTeX-like customs beyond plain MathJax)

原始使用文档
文档目录8 节
  1. Install
  2. Public entrypoints
  3. MathJax setup
  4. Document model basics
  5. Development and demos
  6. Book authoring — proposed only
  7. Documentation
  8. License

BuTeX

BuTeX (@drghaliasri/butex) provides Arabic mathematical typography and structured equation/document editing on MathJax 4. It ships an AST-first equation editor, canonical Document model, React editors/previews and a stateless Node document worker.

MathJax is an external peer dependency, not bundled as a vendored upstream source tree. See MathJax's upstream source for the reference implementation; package.json specifies the runtime peer dependency.

Install

npm install @drghaliasri/butex mathjax
# Add these if using the React editors:
npm install react react-dom

Node.js 20+ is required for tooling/worker usage. MathJax ^4.1.0 is a peer dependency; React and ReactDOM 18/19 are optional peers. package.json defines current versions, supported imports and CLI names.

Public entrypoints

Import / executableImplemented purpose
@drghaliasri/butexCore Arabic MathJax macros, parseBuTeX, registration, math-island rendering
@drghaliasri/butex/reactStandalone ButexEditor equation editor
@drghaliasri/butex/documentDocumentJson, commands, import/export, outline, validation, diff
@drghaliasri/butex/react-documentButexDocumentEditor editor
@drghaliasri/butex/react-document-previewLightweight read-only ButexDocumentPreview
butex-documentStateless stdin / authenticated HTTP worker

The completed Document2 → Document migration retired the first-generation editor and promoted the maintained model, worker and React editor to the unversioned names above. These are the current 8.0.3 package interfaces, not pending migration-branch APIs. See the post-fix verification for evidence and release qualifications.

MathJax setup

Use MathJax 4 tex-chtml.js or tex-svg.js, matching the chtml / svg output mode. Configure the butex-arabic-math TeX package and call registerBuTeX before MathJax startup completes. Use registerBuTeXSvgTextWrapper after startup initialization for SVG-specific Arabic text behavior.

import { registerBuTeX, injectBuTeXStyles } from '@drghaliasri/butex';

// Inside your host's MathJax startup.ready integration:
registerBuTeX(MathJax);
injectBuTeXStyles();
// Then complete the chosen MathJax component's startup.

See math/rendering architecture for initialization and semantic/visual RTL rules. parseBuTeX is a small Arabic-friendly surface preprocessor, not a general LaTeX-to-structured-AST parser.

Document model basics

import {
  createEmptyDocument,
  fromDocumentJson,
  toDocumentJson,
  validateDocument,
} from '@drghaliasri/butex/document';

const document = createEmptyDocument();
const validation = validateDocument(document);
const saved = toDocumentJson(document);
const restored = fromDocumentJson(saved);

Use ButexDocumentEditor from @drghaliasri/butex/react-document for the interactive editor; use ButexDocumentPreview from @drghaliasri/butex/react-document-preview to show read-only snapshots.

Renaming an enabled figure/table label with update_float_meta also updates matching \ref/\eqref tokens throughout the document in the same edit; disabling or clearing a label leaves references unchanged.

Host responsibility: authentication, article permissions, immutable revisions, image uploads/storage, compilation and publishing. BuTeX supplies pure Document transformations and editing UI, never an article database or MCP authorization bypass. See Document, React integration, and the worker.

Development and demos

npm ci
npm run build
npm run typecheck
npm run lint
npm test

The equation-editor demo is demo/editor-app/; the modern document editor is demo/document-editor-app/; the first-generation demo was replaced by the promoted modern demo at the canonical path. Read local development and verification.

Book authoring — proposed only

The BuTeX book design and Al-Bayan integration plan describe future multi-chapter editing, scoped references and whole-book export. Book/editor/worker APIs in those plans do not ship today.

Documentation

  • Architecture — implemented package and host contracts
  • Development — building, browser testing and releases
  • Proposals — book authoring and completed Document migration evidence
  • Archive — historical design records

The npm tarball includes dist/ and this README; docs/ live in the GitLab repository.

License

See the license field in package.json.

版本与发布记录

@drghaliasri/butex 共发布 64 个版本,首次发布于 2026/06/17;过去 12 个月发布了 64 个版本。

版本发布日期距今
8.1.2latest2026/11/14今天
8.1.12026/11/112 天前
8.1.02026/11/104 天前
8.0.32026/11/095 天前
8.0.22026/11/085 天前
8.0.12026/10/2817 天前

关于 @drghaliasri/butex 的常见问题

@drghaliasri/butex 是什么?

MathJax extension layer for Arabic-friendly math notation (XeLaTeX-like customs beyond plain MathJax)

如何安装 @drghaliasri/butex?

在项目目录运行 npm install @drghaliasri/butex,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:mathjax(^4.1.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 butex-document,可以用 npx butex-document 直接运行。

@drghaliasri/butex 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@drghaliasri/butex 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@drghaliasri/butex 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@drghaliasri/butex 可以商用吗?

@drghaliasri/butex 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@drghaliasri/butex 的下载量有多少?

根据 npm 官方下载统计,@drghaliasri/butex 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,092 次,日均约 70 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@drghaliasri/butex 还在维护吗?

最新版本 8.1.2 发布于 2026/11/14(今天);至今共发布 64 个版本,其中过去 12 个月发布了 64 个;首次发布于 2026/06/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。