@asciidoctor/core 3.0.4 → 4.0.0-alpha.2

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.
Files changed (92) hide show
  1. package/README.md +42 -10
  2. package/build/browser/index.js +24156 -0
  3. package/build/node/index.cjs +24737 -0
  4. package/{dist/css/asciidoctor.css → data/asciidoctor-default.css} +54 -53
  5. package/package.json +55 -97
  6. package/src/abstract_block.js +857 -0
  7. package/src/abstract_node.js +954 -0
  8. package/src/attribute_entry.js +12 -0
  9. package/src/attribute_list.js +380 -0
  10. package/src/block.js +168 -0
  11. package/src/browser/asset.js +22 -0
  12. package/src/browser/reader.js +138 -0
  13. package/src/browser.js +121 -0
  14. package/src/callouts.js +85 -0
  15. package/src/compliance.js +54 -0
  16. package/src/constants.js +665 -0
  17. package/src/convert.js +370 -0
  18. package/src/converter/composite.js +83 -0
  19. package/src/converter/docbook5.js +1031 -0
  20. package/src/converter/html5.js +1893 -0
  21. package/src/converter/manpage.js +935 -0
  22. package/src/converter/template.js +459 -0
  23. package/src/converter.js +478 -0
  24. package/src/data/stylesheet-data.js +2 -0
  25. package/src/document.js +2134 -0
  26. package/src/extensions.js +1952 -0
  27. package/src/footnote.js +28 -0
  28. package/src/helpers.js +355 -0
  29. package/src/index.js +138 -0
  30. package/src/inline.js +158 -0
  31. package/src/list.js +240 -0
  32. package/src/load.js +276 -0
  33. package/src/logging.js +526 -0
  34. package/src/parser.js +3661 -0
  35. package/src/path_resolver.js +472 -0
  36. package/src/reader.js +1755 -0
  37. package/src/rx.js +829 -0
  38. package/src/section.js +354 -0
  39. package/src/stylesheets.js +30 -0
  40. package/src/substitutors.js +2241 -0
  41. package/src/syntaxHighlighter/highlightjs.js +90 -0
  42. package/src/syntaxHighlighter/html_pipeline.js +33 -0
  43. package/src/syntax_highlighter.js +304 -0
  44. package/src/table.js +952 -0
  45. package/src/timings.js +78 -0
  46. package/types/abstract_block.d.ts +346 -0
  47. package/types/abstract_node.d.ts +471 -0
  48. package/types/attribute_entry.d.ts +7 -0
  49. package/types/attribute_list.d.ts +52 -0
  50. package/types/block.d.ts +55 -0
  51. package/types/browser/asset.d.ts +7 -0
  52. package/types/browser/reader.d.ts +29 -0
  53. package/types/callouts.d.ts +36 -0
  54. package/types/compliance.d.ts +23 -0
  55. package/types/constants.d.ts +268 -0
  56. package/types/convert.d.ts +34 -0
  57. package/types/converter/composite.d.ts +20 -0
  58. package/types/converter/docbook5.d.ts +41 -0
  59. package/types/converter/html5.d.ts +51 -0
  60. package/types/converter/manpage.d.ts +59 -0
  61. package/types/converter/template.d.ts +83 -0
  62. package/types/converter.d.ts +150 -0
  63. package/types/data/stylesheet-data.d.ts +2 -0
  64. package/types/document.d.ts +495 -0
  65. package/types/extensions.d.ts +876 -0
  66. package/types/footnote.d.ts +18 -0
  67. package/types/helpers.d.ts +146 -0
  68. package/types/index.d.cts +75 -0
  69. package/types/index.d.ts +73 -3731
  70. package/types/inline.d.ts +69 -0
  71. package/types/list.d.ts +114 -0
  72. package/types/load.d.ts +39 -0
  73. package/types/logging.d.ts +187 -0
  74. package/types/parser.d.ts +114 -0
  75. package/types/path_resolver.d.ts +103 -0
  76. package/types/reader.d.ts +184 -0
  77. package/types/rx.d.ts +513 -0
  78. package/types/section.d.ts +122 -0
  79. package/types/stylesheets.d.ts +10 -0
  80. package/types/substitutors.d.ts +208 -0
  81. package/types/syntaxHighlighter/highlightjs.d.ts +33 -0
  82. package/types/syntaxHighlighter/html_pipeline.d.ts +16 -0
  83. package/types/syntax_highlighter.d.ts +167 -0
  84. package/types/table.d.ts +231 -0
  85. package/types/timings.d.ts +25 -0
  86. package/types/tsconfig.json +9 -0
  87. package/LICENSE +0 -21
  88. package/dist/browser/asciidoctor.js +0 -47654
  89. package/dist/browser/asciidoctor.min.js +0 -1452
  90. package/dist/graalvm/asciidoctor.js +0 -47402
  91. package/dist/node/asciidoctor.cjs +0 -21567
  92. 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 Asciidoctor core functionality:
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
- const asciidoctor = require('@asciidoctor/core')() // ①
23
- const content = 'http://asciidoctor.org[*Asciidoctor*] ' +
24
- 'running on https://opalrb.com[_Opal_] ' +
25
- 'brings AsciiDoc to Node.js!'
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. Instantiate the Asciidoctor.js library
30
- 2. Convert AsciiDoc content to HTML5 using Asciidoctor.js
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="http://asciidoctor.org"><strong>Asciidoctor</strong></a> running on <a href="http://opalrb.com"><em>Opal</em></a> brings AsciiDoc to Node.js!</p>
50
+ <p><a href="https://asciidoctor.org"><strong>Asciidoctor</strong></a> running on Node.js!</p>
44
51
  </div>
45
52
  ```
46
53
 
47
- If you want to know more about Asciidoctor.js, please read the [User Manual](https://asciidoctor-docs.netlify.com/asciidoctor.js/).
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