@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.
Files changed (91) hide show
  1. package/README.md +42 -10
  2. package/build/browser/index.js +24154 -0
  3. package/build/node/index.cjs +24735 -0
  4. package/{dist/css/asciidoctor.css → data/asciidoctor-default.css} +54 -53
  5. package/package.json +53 -100
  6. package/src/abstract_block.js +849 -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 +1899 -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 +343 -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.ts +73 -3731
  69. package/types/inline.d.ts +69 -0
  70. package/types/list.d.ts +114 -0
  71. package/types/load.d.ts +39 -0
  72. package/types/logging.d.ts +187 -0
  73. package/types/parser.d.ts +114 -0
  74. package/types/path_resolver.d.ts +103 -0
  75. package/types/reader.d.ts +184 -0
  76. package/types/rx.d.ts +513 -0
  77. package/types/section.d.ts +122 -0
  78. package/types/stylesheets.d.ts +10 -0
  79. package/types/substitutors.d.ts +208 -0
  80. package/types/syntaxHighlighter/highlightjs.d.ts +33 -0
  81. package/types/syntaxHighlighter/html_pipeline.d.ts +16 -0
  82. package/types/syntax_highlighter.d.ts +167 -0
  83. package/types/table.d.ts +231 -0
  84. package/types/timings.d.ts +25 -0
  85. package/types/tsconfig.json +9 -0
  86. package/LICENSE +0 -21
  87. package/dist/browser/asciidoctor.js +0 -47654
  88. package/dist/browser/asciidoctor.min.js +0 -1452
  89. package/dist/graalvm/asciidoctor.js +0 -47402
  90. package/dist/node/asciidoctor.cjs +0 -21567
  91. package/dist/node/asciidoctor.js +0 -23037
@@ -0,0 +1,471 @@
1
+ /**
2
+ * An abstract base class that provides state and methods for managing a node of AsciiDoc content.
3
+ * The state and methods on this class are common to all content segments in an AsciiDoc document.
4
+ * @abstract
5
+ */
6
+ export abstract class AbstractNode {
7
+ /**
8
+ * @param {AbstractNode} parent
9
+ * @param {string} context
10
+ * @param {object} [opts={}]
11
+ */
12
+ constructor(parent: AbstractNode, context: string, opts?: object);
13
+ /** @type {Document} */
14
+ document: Document;
15
+ context: string;
16
+ nodeName: string;
17
+ id: string;
18
+ attributes: any;
19
+ passthroughs: any[];
20
+ /**
21
+ * Alias for {@link setParent}.
22
+ * @see {setParent}
23
+ */
24
+ set parent(parent: AbstractNode);
25
+ /**
26
+ * Alias for {@link getParent}.
27
+ * @see {getParent}
28
+ */
29
+ get parent(): AbstractNode;
30
+ /**
31
+ * Set the value of the role attribute on this node.
32
+ *
33
+ * Accepts a single role name, a space-separated String, or an Array.
34
+ *
35
+ * @param {string|string[]} names - A single role name, a space-separated String, or an Array.
36
+ */
37
+ set role(names: string | string[]);
38
+ /**
39
+ * Alias for {@link getRole}.
40
+ * @see {getRole}
41
+ */
42
+ get role(): string | string[];
43
+ /**
44
+ * Alias for {@link getRoles}.
45
+ * @see {getRoles}
46
+ */
47
+ get roles(): any;
48
+ /**
49
+ * @returns {boolean} true if this AbstractNode is an instance of Block.
50
+ * @throws {Error} Subclasses must override this method.
51
+ */
52
+ isBlock(): boolean;
53
+ /**
54
+ * @returns {boolean} true if this AbstractNode is an instance of Inline.
55
+ * @throws {Error} Subclasses must override this method.
56
+ */
57
+ isInline(): boolean;
58
+ /**
59
+ * Alias for {@link getConverter}.
60
+ * @see {getConverter}
61
+ * @returns {object} the converter instance.
62
+ */
63
+ get converter(): object;
64
+ /**
65
+ * Get the value of the specified attribute.
66
+ *
67
+ * Looks for the attribute on this node first. If not found and `fallbackName` is
68
+ * set, and this node is not the Document node, look for that attribute on the
69
+ * Document node. Otherwise, return `defaultValue`.
70
+ *
71
+ * @param {string} name - The attribute name to resolve.
72
+ * @param {*} [defaultValue=null] - The value to return if the attribute is not found.
73
+ * @param {string|boolean|null} [fallbackName=null] - When truthy, also checks the Document's
74
+ * attributes. Pass `true` to fall back using the same name, or a string to use a different name.
75
+ * @returns {*} the attribute value or defaultValue.
76
+ *
77
+ * @example <caption>Simple lookup</caption>
78
+ * block.getAttribute('language') // → 'ruby' or null
79
+ *
80
+ * @example <caption>With default</caption>
81
+ * block.getAttribute('linenums', false) // → false if not set
82
+ *
83
+ * @example <caption>Inherit from document if absent on block</caption>
84
+ * block.getAttribute('source-highlighter', null, true) // → falls back to doc attribute of same name
85
+ * block.getAttribute('linenums', null, 'source-linenums') // → falls back to 'source-linenums' on doc
86
+ */
87
+ getAttribute(name: string, defaultValue?: any, fallbackName?: string | boolean | null): any;
88
+ /**
89
+ * Check if the specified attribute is defined on this node, with optional
90
+ * value match and document-level fallback.
91
+ *
92
+ * @param {string} name - The attribute name.
93
+ * @param {*} [expectedValue=null] - When truthy, also checks that the resolved value equals this.
94
+ * @param {string|boolean|null} [fallbackName=null] - When truthy, also checks the Document's
95
+ * attributes. Pass `true` to use the same name, or a string for a different fallback name.
96
+ * @returns {boolean}
97
+ *
98
+ * @example <caption>Presence check</caption>
99
+ * block.hasAttribute('linenums') // → true/false
100
+ *
101
+ * @example <caption>Value match</caption>
102
+ * block.hasAttribute('language', 'ruby') // → true only when language === 'ruby'
103
+ *
104
+ * @example <caption>Inherit presence from document</caption>
105
+ * block.hasAttribute('source-highlighter', null, true) // → also checks doc-level attribute
106
+ */
107
+ hasAttribute(name: string, expectedValue?: any, fallbackName?: string | boolean | null): boolean;
108
+ /**
109
+ * Set the value of the specified attribute on this node.
110
+ *
111
+ * @param {string} name - The attribute name to assign.
112
+ * @param {*} [value=''] - The value to assign.
113
+ * @param {boolean} [overwrite=true] - When `false`, does nothing if the attribute already exists.
114
+ * @returns {string|boolean|null} `true` if the attribute was set, `false` if blocked by `overwrite=false`.
115
+ * Subclasses (e.g. `Document`) may return the resolved value string or `null` when the attribute is locked.
116
+ */
117
+ setAttribute(name: string, value?: any, overwrite?: boolean): string | boolean | null;
118
+ /**
119
+ * Check if the specified attribute is defined with an optional value match.
120
+ * Alias for {@link hasAttribute}.
121
+ * @see {hasAttribute}
122
+ */
123
+ isAttribute(name: any, expectedValue?: any): boolean;
124
+ /**
125
+ * Remove the attribute from this node.
126
+ *
127
+ * @param {string} name - The attribute name to remove.
128
+ * @returns {*} the previous value, or `undefined` if the attribute was not present.
129
+ */
130
+ removeAttribute(name: string): any;
131
+ /**
132
+ * Check if the specified option attribute is enabled on this node.
133
+ * This method checks whether the `<name>-option` attribute is set.
134
+ *
135
+ * @param {string} name - The String or Symbol name of the option.
136
+ * @returns {boolean} true if the option is enabled, false otherwise.
137
+ */
138
+ hasOption(name: string): boolean;
139
+ /**
140
+ * Set the specified option on this node by setting the `<name>-option` attribute.
141
+ *
142
+ * @param {string} name - The String name of the option.
143
+ */
144
+ setOption(name: string): void;
145
+ /**
146
+ * Retrieve the Set of option names that are enabled on this node.
147
+ *
148
+ * @returns {Set<string>} a Set of option name strings.
149
+ */
150
+ enabledOptions(): Set<string>;
151
+ /**
152
+ * Update the attributes of this node with the new values.
153
+ *
154
+ * @param {Object} newAttributes - A plain object of additional attributes to assign.
155
+ * @returns {Object} the updated attributes object on this node.
156
+ */
157
+ updateAttributes(newAttributes: any): any;
158
+ /**
159
+ * Check if the `role` attribute is set on this node, optionally matching an exact value.
160
+ *
161
+ * Unlike {@link hasRole}, which checks for an individual role name within a
162
+ * space-separated list, this method tests the raw `role` attribute string as a whole.
163
+ *
164
+ * @param {string|null} [expectedValue=null] - When provided, checks that the `role`
165
+ * attribute equals this string exactly.
166
+ * @returns {boolean}
167
+ *
168
+ * @example
169
+ * node.hasRoleAttribute() // → true if role attribute is set at all
170
+ * node.hasRoleAttribute('lead') // → true only when role === 'lead' (not 'lead primary')
171
+ */
172
+ hasRoleAttribute(expectedValue?: string | null): boolean;
173
+ /**
174
+ * Check if the specified role name is present in this node's role list.
175
+ *
176
+ * @param {string} name - The String role name to find.
177
+ * @returns {boolean}
178
+ */
179
+ hasRole(name: string): boolean;
180
+ /**
181
+ * Add the given role directly to this node.
182
+ *
183
+ * @param {string} name - The String role name to add.
184
+ * @returns {boolean} true if the role was added, false if it was already present.
185
+ */
186
+ addRole(name: string): boolean;
187
+ /**
188
+ * Remove the given role directly from this node.
189
+ *
190
+ * @param {string} name - The String role name to remove.
191
+ * @returns {boolean} true if the role was removed, false if it was not present.
192
+ */
193
+ removeRole(name: string): boolean;
194
+ /**
195
+ * Get the value of the reftext attribute with substitutions applied.
196
+ * The result is pre-computed during Document.parse() via {@link precomputeReftext}.
197
+ * Falls back to the raw reftext attribute if precomputeReftext() has not been called yet.
198
+ *
199
+ * @returns {string|null} the String reftext or null if not set.
200
+ */
201
+ get reftext(): string | null;
202
+ /**
203
+ * Pre-compute the reftext with substitutions applied asynchronously.
204
+ * Called during Document.parse() so the synchronous getter works during conversion.
205
+ *
206
+ * @returns {Promise<void>}
207
+ */
208
+ precomputeReftext(): Promise<void>;
209
+ /**
210
+ * Check if the reftext attribute is defined.
211
+ *
212
+ * @returns {boolean}
213
+ */
214
+ hasReftext(): boolean;
215
+ /**
216
+ * Check whether this node has reftext — either an explicit 'reftext' attribute
217
+ * or a title that can serve as the cross-reference text.
218
+ * Mirrors Ruby's AbstractNode#reftext?
219
+ * @returns {boolean}
220
+ */
221
+ isReftext(): boolean;
222
+ /**
223
+ * Construct a reference or data URI to an icon image for the given name.
224
+ *
225
+ * If the 'icon' attribute is set on this node the name is ignored and the
226
+ * attribute value is used as the target path. Otherwise the icon path is built
227
+ * from 'iconsdir', the name, and 'icontype' (default: 'png').
228
+ *
229
+ * @param {string} name - The String name of the icon.
230
+ * @returns {Promise<string>} a Promise resolving to a String reference or data URI for the icon image.
231
+ */
232
+ iconUri(name: string): Promise<string>;
233
+ /**
234
+ * Construct a URI reference or data URI to the target image.
235
+ *
236
+ * If the target image is already a URI it is left untouched (unless data-uri
237
+ * conversion is requested). The image is resolved relative to the directory
238
+ * named by assetDirKey. When data-uri is enabled and the safe level permits,
239
+ * the image is embedded as a Base64 data URI.
240
+ *
241
+ * NOTE: When the document has both 'data-uri' and 'allow-uri-read' enabled
242
+ * and the resolved image URL is a remote URI, this method returns a Promise
243
+ * rather than a String. Await the result when that combination may be active.
244
+ *
245
+ * @param {string} targetImage - A String path to the target image.
246
+ * @param {string} [assetDirKey='imagesdir'] - The String attribute key for the image directory.
247
+ * @returns {Promise<string>} a Promise resolving to a String reference or data URI.
248
+ */
249
+ imageUri(targetImage: string, assetDirKey?: string): Promise<string>;
250
+ /**
251
+ * Construct a URI reference to the target media.
252
+ *
253
+ * @param {string} target - A String reference to the target media.
254
+ * @param {string} [assetDirKey='imagesdir'] - The String attribute key for the media directory.
255
+ * @returns {string} a String reference for the target media.
256
+ */
257
+ mediaUri(target: string, assetDirKey?: string): string;
258
+ /**
259
+ * Generate a data URI that embeds the image at the given local path.
260
+ *
261
+ * The image path is cleaned to prevent access outside the jail when the
262
+ * document safe level is SafeMode.SAFE or higher. The image data is read
263
+ * and Base64-encoded. In non-Node environments this method returns an empty
264
+ * data URI with a warning.
265
+ *
266
+ * @param {string} targetImage - A String path to the target image.
267
+ * @param {string|null} [assetDirKey=null] - The String attribute key for the image directory.
268
+ * @returns {Promise<string>} a Promise resolving to a String data URI.
269
+ */
270
+ generateDataUri(targetImage: string, assetDirKey?: string | null): Promise<string>;
271
+ /**
272
+ * Read the image data from the specified URI and generate a data URI.
273
+ *
274
+ * The image data is fetched and Base64-encoded. The MIME type is taken from
275
+ * the Content-Type response header.
276
+ *
277
+ * NOTE: This method is async in JS (the Fetch API is async). When called from
278
+ * imageUri, the caller must await the returned Promise.
279
+ *
280
+ * @param {string} imageUri - The URI from which to read the image data (http/https/ftp).
281
+ * @param {boolean} [cacheUri=false] - A Boolean to control caching (not yet supported in JS).
282
+ * @returns {Promise<string>} a Promise resolving to a String data URI.
283
+ */
284
+ generateDataUriFromUri(imageUri: string, cacheUri?: boolean): Promise<string>;
285
+ /**
286
+ * Normalize the asset file or directory to a concrete and rinsed path.
287
+ *
288
+ * Delegates to {@link normalizeSystemPath} with start set to document.baseDir.
289
+ *
290
+ * @param {string} assetRef - The String asset reference to normalize.
291
+ * @param {string} [assetName='path'] - The String label for the asset used in messages.
292
+ * @param {boolean} [autocorrect=true] - A Boolean indicating whether to recover from an illegal path.
293
+ * @returns {string} the normalized String path.
294
+ */
295
+ normalizeAssetPath(assetRef: string, assetName?: string, autocorrect?: boolean): string;
296
+ /**
297
+ * Resolve and normalize a secure path from the target and start paths.
298
+ *
299
+ * Prevents resolving a path outside the jail (defaulting to document.baseDir)
300
+ * when the document safe level is SafeMode.SAFE or higher.
301
+ *
302
+ * @param {string} target - The String target path.
303
+ * @param {string|null} [start=null] - The String start (parent) path.
304
+ * @param {string|null} [jail=null] - The String jail path.
305
+ * @param {Object} [opts={}] - A plain object of options:
306
+ * - `recover` {boolean} - Whether to automatically recover for illegal paths.
307
+ * - `targetName` {string} - Label used in messages for the path being resolved.
308
+ * @throws {Error} if a jail is specified and the resolved path is outside it.
309
+ * @returns {string} the resolved String path.
310
+ */
311
+ normalizeSystemPath(target: string, start?: string | null, jail?: string | null, opts?: any): string;
312
+ /**
313
+ * Normalize the web path using the PathResolver.
314
+ *
315
+ * @param {string} target - The String target path.
316
+ * @param {string|null} [start=null] - The String start (parent) path.
317
+ * @param {boolean} [preserveUriTarget=true] - Whether a URI target should be preserved as-is.
318
+ * @returns {string} the resolved String path.
319
+ */
320
+ normalizeWebPath(target: string, start?: string | null, preserveUriTarget?: boolean): string;
321
+ /**
322
+ * Read the contents of the file at the specified path.
323
+ *
324
+ * This method checks that the file is readable before attempting to read it.
325
+ *
326
+ * @param {string} path - The String path from which to read the contents.
327
+ * @param {Object} [opts={}] - A plain object of options:
328
+ * - `warnOnFailure` {boolean} - Whether a warning is issued when the file cannot be read (default: false).
329
+ * - `normalize` {boolean} - Whether lines are normalized and coerced to UTF-8 (default: false).
330
+ * - `label` {string} - Label for the file used in warning messages.
331
+ * @returns {Promise<string|null>} a Promise resolving to the file content, or null if not readable.
332
+ */
333
+ readAsset(path: string, opts?: any): Promise<string | null>;
334
+ /**
335
+ * Resolve the URI or system path to the target, then read and return its contents.
336
+ *
337
+ * When the resolved path is a URI and allow-uri-read is enabled, the content is
338
+ * fetched via the Fetch API (async). When it is a local path, the file is read
339
+ * via {@link readAsset}.
340
+ *
341
+ * @param {string} target - The URI or local path String from which to read the data.
342
+ * @param {Object} [opts={}] - A plain object of options:
343
+ * - `label` {string} - Label used in warning messages (default: 'asset').
344
+ * - `normalize` {boolean} - Whether the data should be normalized (default: false).
345
+ * - `start` {string} - Relative base path for resolving the target.
346
+ * - `warnOnFailure` {boolean} - Whether warnings are issued on failure (default: true).
347
+ * - `warnIfEmpty` {boolean} - Whether a warning is issued when the target contents are empty (default: false).
348
+ * @returns {Promise<string|null>} a Promise resolving to the content, or null on failure.
349
+ */
350
+ readContents(target: string, opts?: any): Promise<string | null>;
351
+ /**
352
+ * @deprecated Use `isUriish` from helpers.js instead.
353
+ * @param {string} str
354
+ * @returns {boolean}
355
+ */
356
+ isUri(str: string): boolean;
357
+ /**
358
+ * Provide a default logger.
359
+ * The Logging mixin (logging.js) overrides this getter on the prototype.
360
+ */
361
+ get logger(): any;
362
+ /**
363
+ * Get the logger for this node.
364
+ * @returns {object} the logger instance.
365
+ */
366
+ getLogger(): object;
367
+ /**
368
+ * Retrieve the space-separated String role for this node.
369
+ *
370
+ * @returns {string|undefined} the role as a space-separated String.
371
+ */
372
+ getRole(): string | undefined;
373
+ /**
374
+ * Set the value of the role attribute on this node.
375
+ *
376
+ * Accepts a single role name, a space-separated String, an Array, or spread arguments.
377
+ *
378
+ * @param {...string|string[]} names - A single role name, a space-separated String, an Array,
379
+ * or multiple role names as spread arguments.
380
+ * @returns {string} the value of the role attribute.
381
+ */
382
+ setRole(...names: (string | string[])[]): string;
383
+ /**
384
+ * Retrieve the String role names for this node as an Array.
385
+ *
386
+ * @returns {string[]} the role names as a String Array, empty if the role attribute is absent.
387
+ */
388
+ getRoles(): string[];
389
+ /**
390
+ * Get the attributes hash for this node.
391
+ *
392
+ * @returns {Object} a plain Object of attributes.
393
+ */
394
+ getAttributes(): any;
395
+ /**
396
+ * Get the document to which this node belongs.
397
+ *
398
+ * @returns {Document} the Document.
399
+ */
400
+ getDocument(): Document;
401
+ /**
402
+ * Get the parent node of this node.
403
+ *
404
+ * @returns {AbstractNode|undefined} the parent AbstractNode, or undefined for the root document.
405
+ */
406
+ getParent(): AbstractNode | undefined;
407
+ /**
408
+ * Set the parent of this node.
409
+ * Also updates the document reference.
410
+ */
411
+ setParent(parent: any): void;
412
+ /**
413
+ * Get the String name of this node.
414
+ *
415
+ * @returns {string} the node name.
416
+ */
417
+ getNodeName(): string;
418
+ /**
419
+ * Get the String id for this node.
420
+ *
421
+ * @returns {string|undefined} the id, or undefined if not set.
422
+ */
423
+ getId(): string | undefined;
424
+ /**
425
+ * Set the String id for this node.
426
+ *
427
+ * @param {string} id - The String id to assign.
428
+ */
429
+ setId(id: string): void;
430
+ /**
431
+ * Get the context name for this node.
432
+ *
433
+ * @returns {string} the context name.
434
+ */
435
+ getContext(): string;
436
+ /**
437
+ * Get the {Converter} instance being used to convert the current {Document}.
438
+ *
439
+ * @returns {object} the converter instance.
440
+ */
441
+ getConverter(): object;
442
+ /**
443
+ * Get the icon URI for the named icon.
444
+ *
445
+ * @param {string} name - The String icon name.
446
+ * @returns {Promise<string>} a Promise resolving to a String URI.
447
+ */
448
+ getIconUri(name: string): Promise<string>;
449
+ /**
450
+ * Get the media URI for the target.
451
+ *
452
+ * @param {string} target - The String target path or URL.
453
+ * @param {string} [assetDirKey='imagesdir'] - The String asset directory attribute key.
454
+ * @returns {string} a String URI.
455
+ */
456
+ getMediaUri(target: string, assetDirKey?: string): string;
457
+ /**
458
+ * Get the image URI for the target image.
459
+ *
460
+ * @param {string} targetImage - The String target image path or URL.
461
+ * @param {string|null} [assetDirKey=null] - The String asset directory attribute key.
462
+ * @returns {Promise<string>} a Promise resolving to a String URI.
463
+ */
464
+ getImageUri(targetImage: string, assetDirKey?: string | null): Promise<string>;
465
+ /**
466
+ * Get the value of the reftext attribute with substitutions applied.
467
+ *
468
+ * @returns {string|undefined} the reftext value, or undefined if not set.
469
+ */
470
+ getReftext(): string | undefined;
471
+ }
@@ -0,0 +1,7 @@
1
+ export class AttributeEntry {
2
+ constructor(name: any, value: any, negate?: any);
3
+ name: any;
4
+ value: any;
5
+ negate: any;
6
+ saveTo(blockAttributes: any): this;
7
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Handles parsing AsciiDoc attribute lists into a plain object of key/value pairs.
3
+ * By default, attributes must each be separated by a comma and quotes may be used
4
+ * around the value. If a key is not detected, the value is assigned to a 1-based
5
+ * positional key. Positional attributes can be "rekeyed" when given a positionalAttrs
6
+ * array either during parsing or after.
7
+ *
8
+ * @example
9
+ * const attrlist = new AttributeList('astyle')
10
+ * await attrlist.parse()
11
+ * // => { 1: 'astyle' }
12
+ *
13
+ * attrlist.rekey(['style'])
14
+ * // => { 1: 'astyle', style: 'astyle' }
15
+ *
16
+ * @example
17
+ * const attrlist2 = new AttributeList('quote, Famous Person, Famous Book (2001)')
18
+ * await attrlist2.parse(['style', 'attribution', 'citetitle'])
19
+ * // => { 1: 'quote', style: 'quote', 2: 'Famous Person', attribution: 'Famous Person',
20
+ * // 3: 'Famous Book (2001)', citetitle: 'Famous Book (2001)' }
21
+ */
22
+ export class AttributeList {
23
+ /**
24
+ * Assign string keys to the positional (numeric-keyed) values of the given attributes object.
25
+ * @param {Object} attributes - A plain object produced by parse().
26
+ * @param {Array<string|null>} positionalAttrs - Keys to assign (null entries are skipped).
27
+ * @returns {Object} The updated attributes object.
28
+ */
29
+ static rekey(attributes: any, positionalAttrs: Array<string | null>): any;
30
+ constructor(source: any, block?: any, delimiter?: string);
31
+ /**
32
+ * Parse the attribute list and merge the result into the given object.
33
+ * @param {Object} attributes - The target plain object to update.
34
+ * @param {string[]} [positionalAttrs=[]] - An array of keys to assign to positional values.
35
+ * @returns {Promise<Object>} The updated attributes object.
36
+ */
37
+ parseInto(attributes: any, positionalAttrs?: string[]): Promise<any>;
38
+ /**
39
+ * Parse the attribute list and return a plain object of key/value pairs.
40
+ * Subsequent calls return the already-parsed result without re-parsing.
41
+ * @param {string[]} [positionalAttrs=[]] - An array of keys to assign to positional values.
42
+ * @returns {Promise<Object>} A plain object of parsed attributes.
43
+ */
44
+ parse(positionalAttrs?: string[]): Promise<any>;
45
+ /**
46
+ * Rekey the parsed positional attributes using the given key names.
47
+ * @param {string[]} positionalAttrs - An array of keys to assign to positional values.
48
+ * @returns {Object} The updated attributes object.
49
+ */
50
+ rekey(positionalAttrs: string[]): any;
51
+ #private;
52
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Maps block context strings to their default content model.
3
+ * Any context not listed defaults to 'simple'.
4
+ * @type {Object<string, string>}
5
+ */
6
+ export const DEFAULT_CONTENT_MODEL: {
7
+ [x: string]: string;
8
+ };
9
+ /**
10
+ * Methods for managing AsciiDoc content blocks.
11
+ */
12
+ export class Block extends AbstractBlock<string> {
13
+ /**
14
+ * Factory method — mirrors the core Block.create(parent, context, opts) API.
15
+ * @param {AbstractBlock} parent
16
+ * @param {string} context
17
+ * @param {Object} [opts={}]
18
+ * @returns {Block}
19
+ */
20
+ static create(parent: AbstractBlock, context: string, opts?: any): Block;
21
+ /**
22
+ * Initialize an Asciidoctor::Block object.
23
+ * @param {AbstractBlock} parent - The parent AbstractBlock.
24
+ * @param {string} context - The context name (e.g. 'paragraph', 'listing').
25
+ * @param {Object} [opts={}]
26
+ * @param {'compound'|'simple'|'verbatim'|'raw'|'empty'} [opts.content_model] - Defaults to lookup from DEFAULT_CONTENT_MODEL.
27
+ * @param {Object} [opts.attributes] - Attributes to merge in.
28
+ * @param {string|string[]} [opts.source] - Raw source string or lines.
29
+ * @param {'default'|string[]|string|null} [opts.subs]
30
+ * @param {string[]} [opts.default_subs] - Override for default subs (used with subs: 'default').
31
+ */
32
+ constructor(parent: AbstractBlock, context: string, opts?: {
33
+ content_model?: "compound" | "simple" | "verbatim" | "raw" | "empty";
34
+ attributes?: any;
35
+ source?: string | string[];
36
+ subs?: "default" | string[] | string | null;
37
+ default_subs?: string[];
38
+ });
39
+ /** @type {string[]} */
40
+ lines: string[];
41
+ /** @returns {string} Alias for context — consistent with AsciiDoc terminology. */
42
+ get blockname(): string;
43
+ /** @returns {string[]} The source lines for this block (matches the core API). */
44
+ getSourceLines(): string[];
45
+ /** @returns {string} The preprocessed source of this block as a single String. */
46
+ get source(): string;
47
+ /** @returns {string} The source as a single String (alias for the source getter). */
48
+ getSource(): string;
49
+ /**
50
+ * Get the block name (alias for context).
51
+ * @returns {string}
52
+ */
53
+ getBlockName(): string;
54
+ }
55
+ import { AbstractBlock } from './abstract_block.js';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Fetch the text content of a URI.
3
+ *
4
+ * @param {string} uri - The URI to fetch.
5
+ * @returns {Promise<string|null>} the response text, or null on failure.
6
+ */
7
+ export function readBrowserAsset(uri: string): Promise<string | null>;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Resolve an include path in a browser (URI-based) environment.
3
+ *
4
+ * Implements the rules from the browser-include-test, in the same order:
5
+ *
6
+ * Top-level include (includeStack is empty):
7
+ * 1. target starts with file:// → inc_path = relpath = target
8
+ * 2. target is a URI → must descend from baseDir or allow-uri-read; else → link
9
+ * 3. target is an absolute OS path → prepend file:// (or file:///)
10
+ * 4. baseDir == '.' → inc_path = relpath = target (resolved by XMLHttpRequest/fetch)
11
+ * 5. baseDir starts with file:// OR baseDir is not a URI → inc_path = baseDir/target; relpath = target
12
+ * 6. baseDir is an absolute URL → inc_path = baseDir/target; relpath = target
13
+ *
14
+ * Nested include (includeStack is non-empty):
15
+ * Rules 1–3 same as top-level.
16
+ * 4. parentDir == '.' → inc_path = relpath = target
17
+ * 5. parentDir starts with file:// OR parentDir is not a URI
18
+ * → inc_path = parentDir/target
19
+ * → relpath = inc_path if baseDir=='.' or inc_path not under baseDir, else path difference
20
+ * 6. parentDir is an absolute URL
21
+ * → must descend from baseDir or allow-uri-read; else → link
22
+ * → inc_path = parentDir/target
23
+ * → relpath = path difference if parentDir descends from baseDir, else target
24
+ * @param {object} reader - a PreprocessorReader instance
25
+ * @param {string} target - the raw include target string
26
+ * @param {string|null} attrlist - the raw attribute list string
27
+ * @returns {[string, string]|boolean} [incPath, relpath] on success, or boolean when the line was consumed.
28
+ */
29
+ export function resolveBrowserIncludePath(reader: object, target: string, attrlist: string | null): [string, string] | boolean;
@@ -0,0 +1,36 @@
1
+ /** Maintains a catalog of callouts and their associations. */
2
+ export class Callouts {
3
+ /**
4
+ * Register a new callout for the given list item ordinal.
5
+ * @param {number} liOrdinal - The 1-based ordinal of the list item.
6
+ * @returns {string} The unique id of this callout (e.g. 'CO1-1').
7
+ */
8
+ register(liOrdinal: number): string;
9
+ /**
10
+ * Get the next callout id in document order (used during conversion).
11
+ * @returns {string|null} The unique id of the next callout, or null.
12
+ */
13
+ readNextId(): string | null;
14
+ /**
15
+ * Get a space-separated list of callout ids for the given list item.
16
+ * @param {number} liOrdinal - The 1-based ordinal of the list item.
17
+ * @returns {string} Space-separated callout ids.
18
+ */
19
+ getCalloutIds(liOrdinal: number): string;
20
+ /** @returns {Array<{ordinal: number, id: string}>} The callout objects at the current list index. */
21
+ getCurrentList(): Array<{
22
+ ordinal: number;
23
+ id: string;
24
+ }>;
25
+ /** @returns {Array<Array<{ordinal: number, id: string}>>} All callout lists in the document. */
26
+ getLists(): Array<Array<{
27
+ ordinal: number;
28
+ id: string;
29
+ }>>;
30
+ /** @returns {number} The 1-based index of the current callout list. */
31
+ getListIndex(): number;
32
+ /** Advance to the next callout list in the document. */
33
+ nextList(): void;
34
+ /** Rewind the list pointer to the beginning (switching parse → convert). */
35
+ rewind(): void;
36
+ }