@atlaskit/editor-bitbucket-transformer

中文文档
10.2.3发布于 2026/09/17Apache-2.0TypeScriptESM + CJS近 30 天下载 7318

Editor Bitbucket transformer

原始使用文档
文档目录12 节
  1. Description
  2. Key Features
  3. Transformers
  4. Caption Escaping Pipeline
  5. Examples
  6. Team
  7. Caption escaping and the Markdown/HTML/ADF pipeline
  8. Why escaping captions is tricky
  9. Unified attribute escaping
  10. End-to-end flow
  11. Migration
  12. Security considerations

@atlaskit/editor-bitbucket-transformer

Editor Bitbucket transformer for converting between ADF, Markdown, and HTML formats.

Description

This package provides transformation utilities specifically designed for Bitbucket's editor integration. It handles the complex pipeline of converting between ADF (Atlassian Document Format), Markdown, and HTML, with special focus on caption escaping and attribute preservation through the transformation process.

Key Features

Transformers

  • Serializer: Main serialization utilities for ADF to Markdown conversion
  • Table Serializer: Specialized table transformation handling
  • Utility Functions: Common transformation utilities

Caption Escaping Pipeline

  • HTML Attribute Escaping: Safely escapes captions for Markdown storage
  • Unified Escaping Strategy: Handles both HTML meta characters and Markdown punctuation
  • Round-trip Safety: Ensures data integrity through ADF → Markdown → HTML → ADF pipeline

Examples

The package includes comprehensive examples in the examples/ directory:

  • Basic transformer example
  • Bitbucket HTML handling
  • Bitbucket Markdown processing
  • Helper utilities and styling

Team

Editor: Collaboration

Caption escaping and the Markdown/HTML/ADF pipeline

This package serializes ADF to Markdown for storage, and later reconstructs ADF from HTML that is rendered by the backend using python-markdown. Image captions are stored in Markdown using python-markdown’s attr_list syntax on the image:

![](http://path/to/image.jpg){: data-layout='center' data-caption='...'}

Why escaping captions is tricky

  • python-markdown parses Markdown first, then applies attr_list to bind attributes to elements. If caption text inside data-caption contains Markdown markers (e.g. **, __, `, ~~), those markers can be interpreted during Markdown parsing.
  • When Markdown markers are interpreted within the attribute text, the attribute list can be malformed or ejected, resulting in the attributes not being set on the element (e.g. losing data-caption).

Unified attribute escaping

To ensure captions survive the Markdown → HTML transformation safely, we use a unified escaping strategy:

  • escapeHtmlAttribute(text): Escapes both HTML attribute meta characters (&, <, >, ", ') and Markdown/attr_list-sensitive punctuation by converting them into numeric entities:

    • * → &#42;, _ → &#95;, ` → &#96;, ~ → &#126;
    • | → &#124;, { → &#123;, } → &#125;
    • [ → &#91;, ] → &#93;, ( → &#40;, ) → &#41;, ! → &#33;
  • This prevents python-markdown from interpreting the caption content as Markdown or as part of an attr_list, preserving the attribute safely.

  • unescapeHtmlAttribute(text): Decodes the same superset of entities when reading back from HTML into ADF. Decoding is order-sensitive—&amp; is decoded last to prevent double-unescape issues. After unescaping, we sanitize and parse a limited subset of Markdown formatting for display (**, _, ~~, and `) into safe HTML tags we control.

End-to-end flow

  1. ADF → Markdown (bbc-frontbucket - using this package):
    • Captions are serialized into data-caption using escapeHtmlAttribute to encode HTML meta characters and Markdown punctuation.
  2. Markdown → HTML (bbc-core):
    • python-markdown takes markdown renders HTML and applies attr_list.
    • Because punctuation was entity-encoded, the attributes remain intact even if the caption contains Markdown markers or {...}-like text.
  3. HTML → ADF (frontend):
    • We read data-caption from the html and call unescapeHtmlAttribute, which decodes both HTML and punctuation entities.
    • We then sanitize and parse a safe subset of Markdown to generate ADF caption nodes (e.g., <strong>, <em>, <s>, <code>).

Migration

  • escapeAttrListValue has been removed. Use escapeHtmlAttribute and unescapeHtmlAttribute.

Security considerations

  • We always encode < and > in attributes and, when parsing back from HTML, we sanitize caption content before any Markdown formatting is converted to HTML.
  • Our Markdown parsing is intentionally minimal and maps directly to a small set of safe tags.

版本与发布记录

@atlaskit/editor-bitbucket-transformer 共发布 304 个版本,首次发布于 2017/12/05;过去 12 个月发布了 12 个版本。

版本发布日期距今
10.2.3latest2026/09/171 个月前
10.2.22026/09/091 个月前
10.2.12026/09/032 个月前
10.2.02026/08/302 个月前
10.1.22026/08/242 个月前
10.1.12026/08/202 个月前

其他发布通道:next → 8.1.3。

关于 @atlaskit/editor-bitbucket-transformer 的常见问题

@atlaskit/editor-bitbucket-transformer 是什么?

Editor Bitbucket transformer

如何安装 @atlaskit/editor-bitbucket-transformer?

在项目目录运行 npm install @atlaskit/editor-bitbucket-transformer,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.2.0 || ^19.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atlaskit/editor-bitbucket-transformer 支持 TypeScript 吗?

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

@atlaskit/editor-bitbucket-transformer 支持 ESM 还是 CommonJS?

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

@atlaskit/editor-bitbucket-transformer 可以商用吗?

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

@atlaskit/editor-bitbucket-transformer 的下载量有多少?

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

@atlaskit/editor-bitbucket-transformer 还在维护吗?

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