@asciidoctor/tabs

中文文档
1.0.0-beta.6发布于 2023/08/01MITCommonJS零依赖近 30 天下载 4.5万

An Asciidoctor.js extension that adds a tabs block to the AsciiDoc syntax.

原始使用文档
文档目录6 节
  1. Install
  2. Syntax
  3. Usage
  4. CLI
  5. API
  6. Copyright and License

Asciidoctor Tabs

An Asciidoctor.js extension that adds a tabs block to the AsciiDoc syntax.

Install

This package depends on the asciidoctor package (>= 2.2.0, < 3.0.0), but doesn’t declare it as a dependency. Therefore, you must install that package when installing this one.

$ npm i asciidoctor @asciidoctor/tabs

Syntax

A tabset is defined using a description list (dlist) enclosed in an example block annotated with the tabs style.

[tabs]
====
Tab A:: Contents of Tab A.

Tab B::
+
Contents of Tab B.

Tab C::
+
--
Contents of Tab C.

Contains more than one block.
--
====

You may choose to extend the block delimiter length from the typical 4 characters to 6 in order to avoid conflicts with any example blocks inside the tabs block (or just as a matter of style).

[tabs]
======
Tab A::
+
====
Example block in Tab A.
====

Tab B:: Just text.
======

Using this technique, you can also create nested tabsets.

[tabs]
======
Tab A::
+
Selecting Tab A reveals a tabset with Tab Y and Tab Z.
+
[tabs]
====
Tab Y:: Contents of Tab Y, nested inside Tab A.
Tab Z:: Contents of Tab Z, nested inside Tab A.
====

Tab B:: Just text.
======

Usage

CLI

$ npx asciidoctor -r @asciidoctor/tabs tabs.adoc

The asciidoctor command automatically registers the tabs extension when the package is required.

API

There are two ways to use the extension with the Asciidoctor.js API. In either case, you must require the Asciidoctor.js module (asciidoctor) before requiring this one.

You can call the exported register method with no arguments to register the extension as a global extension.

const Asciidoctor = require('asciidoctor')()

require('@asciidoctor/tabs').register()

Asciidoctor.convertFile('tabs.adoc', { safe: 'safe' })

Or you can pass a registry instance to the register method to register the extension with a scoped registry.

const Asciidoctor = require('asciidoctor')()

const registry = Asciidoctor.Extensions.create()
require('@asciidoctor/tabs').register(registry)

Asciidoctor.convertFile('tabs.adoc', { extension_registry: registry, safe: 'safe' })

You can also require @asciidoctor/tabs/extensions to access the Extensions class. Attached to that object are the Block, Docinfo.Style, and Docinfo.Behavior extension classes. You can use these classes to register a bespoke tabs extension.

Copyright (C) 2018-present Dan Allen (OpenDevise Inc.) and the individual contributors to this project. Use of this software is granted under the terms of the MIT License.

版本与发布记录

@asciidoctor/tabs 共发布 18 个版本,首次发布于 2022/10/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.0-beta.6latest2023/08/013 年前
1.0.0-beta.52023/05/283 年前
1.0.0-beta.42023/05/233 年前
1.0.0-beta.32023/02/013 年前
1.0.0-beta.22023/01/303 年前
1.0.0-beta.12023/01/303 年前

关于 @asciidoctor/tabs 的常见问题

@asciidoctor/tabs 是什么?

An Asciidoctor.js extension that adds a tabs block to the AsciiDoc syntax.

如何安装 @asciidoctor/tabs?

在项目目录运行 npm install @asciidoctor/tabs,或使用 pnpm add / yarn add / bun add。

@asciidoctor/tabs 支持 TypeScript 吗?

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

@asciidoctor/tabs 支持 ESM 还是 CommonJS?

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

@asciidoctor/tabs 需要什么版本的 Node.js?

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

@asciidoctor/tabs 可以商用吗?

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

@asciidoctor/tabs 的下载量有多少?

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

@asciidoctor/tabs 还在维护吗?

最新版本 1.0.0-beta.6 发布于 2023/08/01(3 年前);至今共发布 18 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/10/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。