@asciidoctor/core 3.0.4 → 4.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -10
- package/build/browser/index.js +24154 -0
- package/build/node/index.cjs +24735 -0
- package/{dist/css/asciidoctor.css → data/asciidoctor-default.css} +54 -53
- package/package.json +53 -100
- package/src/abstract_block.js +849 -0
- package/src/abstract_node.js +954 -0
- package/src/attribute_entry.js +12 -0
- package/src/attribute_list.js +380 -0
- package/src/block.js +168 -0
- package/src/browser/asset.js +22 -0
- package/src/browser/reader.js +138 -0
- package/src/browser.js +121 -0
- package/src/callouts.js +85 -0
- package/src/compliance.js +54 -0
- package/src/constants.js +665 -0
- package/src/convert.js +370 -0
- package/src/converter/composite.js +83 -0
- package/src/converter/docbook5.js +1031 -0
- package/src/converter/html5.js +1899 -0
- package/src/converter/manpage.js +935 -0
- package/src/converter/template.js +459 -0
- package/src/converter.js +478 -0
- package/src/data/stylesheet-data.js +2 -0
- package/src/document.js +2134 -0
- package/src/extensions.js +1952 -0
- package/src/footnote.js +28 -0
- package/src/helpers.js +355 -0
- package/src/index.js +138 -0
- package/src/inline.js +158 -0
- package/src/list.js +240 -0
- package/src/load.js +276 -0
- package/src/logging.js +526 -0
- package/src/parser.js +3661 -0
- package/src/path_resolver.js +472 -0
- package/src/reader.js +1755 -0
- package/src/rx.js +829 -0
- package/src/section.js +354 -0
- package/src/stylesheets.js +30 -0
- package/src/substitutors.js +2241 -0
- package/src/syntaxHighlighter/highlightjs.js +90 -0
- package/src/syntaxHighlighter/html_pipeline.js +33 -0
- package/src/syntax_highlighter.js +304 -0
- package/src/table.js +952 -0
- package/src/timings.js +78 -0
- package/types/abstract_block.d.ts +343 -0
- package/types/abstract_node.d.ts +471 -0
- package/types/attribute_entry.d.ts +7 -0
- package/types/attribute_list.d.ts +52 -0
- package/types/block.d.ts +55 -0
- package/types/browser/asset.d.ts +7 -0
- package/types/browser/reader.d.ts +29 -0
- package/types/callouts.d.ts +36 -0
- package/types/compliance.d.ts +23 -0
- package/types/constants.d.ts +268 -0
- package/types/convert.d.ts +34 -0
- package/types/converter/composite.d.ts +20 -0
- package/types/converter/docbook5.d.ts +41 -0
- package/types/converter/html5.d.ts +51 -0
- package/types/converter/manpage.d.ts +59 -0
- package/types/converter/template.d.ts +83 -0
- package/types/converter.d.ts +150 -0
- package/types/data/stylesheet-data.d.ts +2 -0
- package/types/document.d.ts +495 -0
- package/types/extensions.d.ts +876 -0
- package/types/footnote.d.ts +18 -0
- package/types/helpers.d.ts +146 -0
- package/types/index.d.ts +73 -3731
- package/types/inline.d.ts +69 -0
- package/types/list.d.ts +114 -0
- package/types/load.d.ts +39 -0
- package/types/logging.d.ts +187 -0
- package/types/parser.d.ts +114 -0
- package/types/path_resolver.d.ts +103 -0
- package/types/reader.d.ts +184 -0
- package/types/rx.d.ts +513 -0
- package/types/section.d.ts +122 -0
- package/types/stylesheets.d.ts +10 -0
- package/types/substitutors.d.ts +208 -0
- package/types/syntaxHighlighter/highlightjs.d.ts +33 -0
- package/types/syntaxHighlighter/html_pipeline.d.ts +16 -0
- package/types/syntax_highlighter.d.ts +167 -0
- package/types/table.d.ts +231 -0
- package/types/timings.d.ts +25 -0
- package/types/tsconfig.json +9 -0
- package/LICENSE +0 -21
- package/dist/browser/asciidoctor.js +0 -47654
- package/dist/browser/asciidoctor.min.js +0 -1452
- package/dist/graalvm/asciidoctor.js +0 -47402
- package/dist/node/asciidoctor.cjs +0 -21567
- package/dist/node/asciidoctor.js +0 -23037
package/README.md
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
# Asciidoctor core
|
|
2
2
|
|
|
3
|
-
This package provides
|
|
3
|
+
This package provides a native JavaScript implementation of Asciidoctor.
|
|
4
|
+
The code was generated from the Ruby source using [Claude Code](https://claude.ai/code) (claude-sonnet-4-6) and reviewed by a human.
|
|
5
|
+
It is a pure ESM library that exposes the same functionality:
|
|
4
6
|
|
|
5
7
|
* parser
|
|
6
8
|
* built-in converters
|
|
7
9
|
* extensions
|
|
8
10
|
|
|
11
|
+
The API is asynchronous: all parsing and conversion operations return a `Promise`.
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
Node.js >= 24
|
|
16
|
+
|
|
9
17
|
## Install
|
|
10
18
|
|
|
11
19
|
```console
|
|
@@ -19,15 +27,14 @@ Here is a simple example that converts AsciiDoc to HTML5:
|
|
|
19
27
|
**sample.js**
|
|
20
28
|
|
|
21
29
|
```javascript
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const html = asciidoctor.convert(content) // ②
|
|
30
|
+
import { convert } from '@asciidoctor/core' // ①
|
|
31
|
+
|
|
32
|
+
const content = 'https://asciidoctor.org[*Asciidoctor*] running on Node.js!'
|
|
33
|
+
const html = await convert(content) // ②
|
|
27
34
|
console.log(html) // ③
|
|
28
35
|
```
|
|
29
|
-
1.
|
|
30
|
-
2. Convert AsciiDoc content to HTML5
|
|
36
|
+
1. Import `convert` from the Asciidoctor native library (ESM, named export)
|
|
37
|
+
2. Convert AsciiDoc content to HTML5 — the call returns a `Promise` and must be awaited
|
|
31
38
|
3. Print the HTML5 output to the console
|
|
32
39
|
|
|
33
40
|
Save the file as _sample.js_ and run it using the `node` command:
|
|
@@ -40,11 +47,36 @@ You should see the following output in your terminal:
|
|
|
40
47
|
|
|
41
48
|
```html
|
|
42
49
|
<div class="paragraph">
|
|
43
|
-
<p><a href="
|
|
50
|
+
<p><a href="https://asciidoctor.org"><strong>Asciidoctor</strong></a> running on Node.js!</p>
|
|
44
51
|
</div>
|
|
45
52
|
```
|
|
46
53
|
|
|
47
|
-
|
|
54
|
+
### Convert a file
|
|
55
|
+
|
|
56
|
+
**convert-file.js**
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
import { convertFile } from '@asciidoctor/core'
|
|
60
|
+
|
|
61
|
+
const html = await convertFile('document.adoc', { safe: 'safe' })
|
|
62
|
+
console.log(html)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Load without converting
|
|
66
|
+
|
|
67
|
+
Use `load` when you need to inspect the parsed document model before (or instead of) converting:
|
|
68
|
+
|
|
69
|
+
**load.js**
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
import { load } from '@asciidoctor/core'
|
|
73
|
+
|
|
74
|
+
const doc = await load('== Hello, World!\n\nThis is Asciidoctor core.')
|
|
75
|
+
console.log(doc.getTitle()) // Hello, World!
|
|
76
|
+
console.log(doc.getBlocks()) // array of top-level blocks
|
|
77
|
+
const html = await doc.convert()
|
|
78
|
+
console.log(html)
|
|
79
|
+
```
|
|
48
80
|
|
|
49
81
|
## Changelog
|
|
50
82
|
|