Licence
MIT
Version
4.0.0
Deps
0
Size
2.7 MB
Vulns
0
Weekly
140.0K
Asciidoctor core
This package provides a native JavaScript implementation of Asciidoctor. The code was generated from the Ruby source using Claude Code (claude-sonnet-4-6) and reviewed by a human. It is a pure ESM library that exposes the same functionality:
- parser
- built-in converters
- extensions
The API is asynchronous: all parsing and conversion operations return a Promise.
Requirements
Node.js >= 24
Install
$ npm i @asciidoctor/core --save
Usage
Here is a simple example that converts AsciiDoc to HTML5:
sample.js
import { convert } from '@asciidoctor/core' // ①
const content = 'https://asciidoctor.org[*Asciidoctor*] running on Node.js!'
const html = await convert(content) // ②
console.log(html) // ③- Import
convertfrom the Asciidoctor native library (ESM, named export) - Convert AsciiDoc content to HTML5 — the call returns a
Promiseand must be awaited - Print the HTML5 output to the console
Save the file as sample.js and run it using the node command:
$ node sample.js
You should see the following output in your terminal:
<div class="paragraph">
<p><a href="https://asciidoctor.org"><strong>Asciidoctor</strong></a> running on Node.js!</p>
</div>Convert a file
convert-file.js
import { convertFile } from '@asciidoctor/core'
const html = await convertFile('document.adoc', { safe: 'safe' })
console.log(html)Load without converting
Use load when you need to inspect the parsed document model before (or instead of) converting:
load.js
import { load } from '@asciidoctor/core'
const doc = await load('== Hello, World!\n\nThis is Asciidoctor core.')
console.log(doc.getTitle()) // Hello, World!
console.log(doc.getBlocks()) // array of top-level blocks
const html = await doc.convert()
console.log(html)Changelog
Refer to the CHANGELOG for a complete list of changes.