@adobe/helix-md2jcr

中文文档
1.5.19发布于 2026/10/28Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2803

Helix Service that converts markdown to JCR content structure

原始使用文档
文档目录9 节
  1. Status
  2. Development
  3. Usage
  4. Installation
  5. Converting Markdown to JCR Nodes
  6. Programmatic Usage
  7. Documentation
  8. Baseline XML Files
  9. Running Tests

Helix Markdown to JCR

A library that converts markdown to JCR.

Status

codecov GitHub license GitHub issues semantic-release

Development

Install all dependencies by running:

npm install

Usage

Installation

You can install the package via npm:

npm install @adobe/helix-md2jcr

Or use it directly with npx without installing:

npx @adobe/helix-md2jcr path/to/content.md

Converting Markdown to JCR Nodes

The package includes a CLI tool md2jcr that converts markdown files to JCR XML format.

Basic usage:

npx @adobe/helix-md2jcr path/to/content.md

Convert a single file:

md2jcr test/fixtures/simple.md

Convert all markdown files in a directory:

md2jcr test/fixtures/

View output in console with verbose flag -v:

md2jcr test/fixtures/simple.md -v

View decoded XML output with -v and -d flags:

md2jcr test/fixtures/simple.md -v -d

Use custom Universal Editor files from a directory:

md2jcr content.md -ue path/to/ue-files-directory

The converter will generate a .xml file alongside the markdown file containing the JCR structure. This can be used to check for potential content changes due to conversion.

Command-Line Options

  • -v, --verbose - Print the XML output to the console
  • -d, --decode - Decode HTML entities in the XML output (use with -v)
  • -ue, --ue-files <directory> - Specify a directory containing Universal Editor configuration files

Example directory structure:

ue-files/
  ├── component-models.json
  ├── component-definition.json
  └── component-filters.json

Programmatic Usage

You can also use the library programmatically in your Node.js code:

import { md2jcr } from '@adobe/helix-md2jcr';

const markdown = '# Hello World\n\nThis is a test.';
const options = {
  models: [...],
  definition: {...},
  filters: [...]
};

const xml = await md2jcr(markdown, options);
console.log(xml);

Documentation

  • Container Blocks — how container blocks map parent properties and child items (the one-column / many-column rules, omitting parent rows, and error cases). See also the container-block test fixtures for a worked scenario-by-scenario breakdown.
  • Block Options (Classes) — block option classes and element grouping (classes, classes_*): how header options are routed to fields by their options or boolean name-suffix.
  • Section Styles — element grouping for a section's style group (style, style_*): how the single Section Metadata style cell is routed back to fields, mirroring block options.
  • Field Hinting — using <!-- field: name --> to skip ahead within a field group.
  • Phrasing Content — supported inline HTML tags (sup, sub, u, del, strong, em) and how they survive the markdown → JCR pipeline.

Baseline XML Files

Running the ./baseline-tests.sh script will detect any md file under test/fixtures and execute the convert2jcr node script.
The script will generate new xml files beside the md files it locates. This is helpful when making changes to the converter and you want to see if the changes have any impact on the output. By using git diff, you will see the new changes in the xml files. If you are satisfied with the changes, you can commit the new xml files.

Running Tests

Simply execute the following command to run the tests:

npm test

版本与发布记录

@adobe/helix-md2jcr 共发布 96 个版本,首次发布于 2025/01/28;过去 12 个月发布了 37 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.5.19latest2026/10/2811 天前
1.5.182026/10/2711 天前
1.5.172026/10/2018 天前
1.5.162026/10/1820 天前
1.5.152026/10/1326 天前
1.5.142026/10/1127 天前

关于 @adobe/helix-md2jcr 的常见问题

@adobe/helix-md2jcr 是什么?

Helix Service that converts markdown to JCR content structure

如何安装 @adobe/helix-md2jcr?

在项目目录运行 npm install @adobe/helix-md2jcr,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 md2jcr,可以用 npx md2jcr 直接运行。

@adobe/helix-md2jcr 支持 TypeScript 吗?

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

@adobe/helix-md2jcr 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adobe/helix-md2jcr 可以商用吗?

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

@adobe/helix-md2jcr 的下载量有多少?

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

@adobe/helix-md2jcr 还在维护吗?

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