# @adobe/htlengine 中文文档

规范地址：https://npmcn.com/package/%40adobe/htlengine/

版本：6\.4\.50
npm 元数据更新时间：2026-10-23T04:00:33.007Z
中文译文更新时间：2026-11-05T22:50:22.395Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40adobe/htlengine
原文对照：https://npmcn.com/package/%40adobe/htlengine/?lang=original
项目主页：https://github.com/adobe/htlengine#readme
源码仓库：https://github.com/adobe/htlengine

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：363 kB，110 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：\>=14
- 运行依赖：14 个
- 首次发布：2018-06-07T22:59:26.360Z
- 最新版本发布：2026-10-23T04:00:32.648Z
- 近 30 天下载量：10704（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：234（近 12 个月 15 个）

## 中文简介

Javascript 基于 HTL (视觉) 解析器

## 安装

```sh
npm install @adobe/htlengine
```

也可以使用：`pnpm add @adobe/htlengine`、`yarn add @adobe/htlengine`、`bun add @adobe/htlengine`

## README

# Javascript 的 HTL 引擎

此引擎可以解析 [HTL 数字](https://github.com/Adobe-Marketing-Cloud/htl-spec) 脚本并构建命令流. 命令流可以被预取出或者用于生成代码. 这个工程提供了一个 Javascript (ES6) 生成器和运行时间, 允许执行脚本和使用类 .

## 状态

[![codecov](https://img.shields.io/codecov/c/github/adobe/htlengine.svg)](https://codecov.io/gh/adobe/htlengine) [![CircleCI](https://img.shields.io/circleci/project/github/adobe/htlengine.svg)](https://circleci.com/gh/adobe/htlengine) [![GitHub license](https://img.shields.io/github/license/adobe/htlengine.svg)](https://github.com/adobe/htlengine/blob/main/LICENSE.txt) [![GitHub issues](https://img.shields.io/github/issues/adobe/htlengine.svg)](https://github.com/adobe/htlengine/issues)

[![LGTM Code Quality Grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/adobe/htlengine.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/adobe/htlengine)

## 安装

```bash
npm install @adobe/htlengine
```

## 构建

```bash
npm install
```

## 运行

现在不太酷。 只将给定的文件传递到 HTML 解析器中,然后再次输出树 .

```bash
node src/cli.js test/simple2.html
```

## 网络软件包

使用 HTL 模板 Wth 网页包编译 [装填器](https://github.com/backflip/htl-loader)

## API 密码

您也可以直接使用 API :

```javascript
const { Compiler } = require('@adobe/htlengine');

const compiler = new Compiler()
      .withDirectory('')
      .includeRuntime(true)
      .withRuntimeGlobalName('it');

const js = await compiler.compileToString(code);
// the result can be saved as a file or eval'd
```

## 实例

-   见 [HAST 示例](https://npmcn.com/package/%40adobe/htlengine/examples/hast/index.js) 使用一个 [抓紧](https://github.com/syntax-tree/hast) 树作为资源文档.
-   见 [JSDOM 示例](https://npmcn.com/package/%40adobe/htlengine/examples/jsdom/index.js) 使用一个 [日记](https://github.com/jsdom/jsdom) 文档为资源.

## 测试

测试更为全面。 它们验证HTL表达式是否被解析并使用生成的解析树重新创建.

```bash
npm test
```

## 生成的重建 [近地点](https://nearley.js.org/) 语法

```bash
npm run build
```

## 常见问题

### @adobe/htlengine 是什么？

Javascript 基于 HTL \(视觉\) 解析器

### 如何安装 @adobe/htlengine？

在项目目录运行 npm install @adobe/htlengine，或使用 pnpm add / yarn add / bun add。

### @adobe/htlengine 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/adobe\_\_htlengine 是否存在。

### @adobe/htlengine 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @adobe/htlengine 需要什么版本的 Node\.js？

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

### @adobe/htlengine 可以商用吗？

@adobe/htlengine 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @adobe/htlengine 的下载量有多少？

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

### @adobe/htlengine 还在维护吗？

最新版本 6\.4\.50 发布于 2026/10/23（15 天前）；至今共发布 234 个版本，其中过去 12 个月发布了 15 个；首次发布于 2018/06/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

