@asciidoctor/core 4.0.0-alpha.1 → 4.0.0-alpha.3

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/src/load.js CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  import { SpaceDelimiterRx, EscapedSpaceRx } from './rx.js'
19
19
  import { NULL, BACKEND_ALIASES } from './constants.js'
20
- import { LoggerManager, NullLogger } from './logging.js'
20
+ import { NullLogger, withLogger, getContextLogger } from './logging.js'
21
21
  import { basename, extname } from './helpers.js'
22
22
  import { Document } from './document.js'
23
23
  import { Converter } from './converter.js'
@@ -58,17 +58,23 @@ export async function load(input, options = {}) {
58
58
  // Shallow-copy options so we don't mutate the caller's object.
59
59
  options = Object.assign({}, options)
60
60
 
61
- const timings = options.timings ?? null
62
- if (timings) timings.start('read')
63
-
64
61
  // ── Logger override ───────────────────────────────────────────────────────
62
+ // When a logger option is supplied, run the conversion in an async-local
63
+ // context so the logger is scoped to this call only — no global mutation,
64
+ // which makes concurrent callers (e.g. parallel Deno tests) safe.
65
65
  if ('logger' in options) {
66
- const logger = options.logger
67
- if (logger !== LoggerManager.logger) {
68
- LoggerManager.logger = logger ?? new NullLogger()
69
- }
66
+ const newLogger = options.logger ?? new NullLogger()
67
+ delete options.logger
68
+ return withLogger(newLogger, () => _doLoad(input, options, newLogger))
70
69
  }
71
70
 
71
+ return _doLoad(input, options)
72
+ }
73
+
74
+ async function _doLoad(input, options, explicitLogger = null) {
75
+ const timings = options.timings ?? null
76
+ if (timings) timings.start('read')
77
+
72
78
  // ── Attributes normalisation ──────────────────────────────────────────────
73
79
  let attrs = options.attributes
74
80
  if (!attrs) {
@@ -100,11 +106,9 @@ export async function load(input, options = {}) {
100
106
  attrs.docname = basename(inputPath, docfilesuffix)
101
107
  }
102
108
  source = await _readStream(input)
103
- } else if (
104
- typeof input === 'object' &&
105
- input?.constructor?.name === 'Buffer'
106
- ) {
107
- source = input.toString('utf8')
109
+ } else if (input instanceof Uint8Array) {
110
+ // Covers both Node.js Buffer (a Uint8Array subclass) and browser Uint8Array shims.
111
+ source = new TextDecoder('utf-8').decode(input)
108
112
  } else if (typeof input === 'string') {
109
113
  source = input
110
114
  } else if (Array.isArray(input)) {
@@ -167,6 +171,19 @@ export async function load(input, options = {}) {
167
171
  }
168
172
 
169
173
  if (timings) timings.record('parse')
174
+
175
+ // Persist the logger on the Document instance so that doc.convert()
176
+ // (called by convert.js after the async-local context ends) still routes
177
+ // logging through the caller-supplied logger.
178
+ // ALS provides it in Node.js/Deno; the explicit parameter covers browser fallback.
179
+ const contextLogger = getContextLogger() ?? explicitLogger
180
+ if (contextLogger) {
181
+ Object.defineProperty(doc, 'logger', {
182
+ get: () => contextLogger,
183
+ configurable: true,
184
+ })
185
+ }
186
+
170
187
  return doc
171
188
  }
172
189
 
package/src/logging.js CHANGED
@@ -39,6 +39,65 @@ function resolveSeverity(severity) {
39
39
  return severity ?? Severity.UNKNOWN
40
40
  }
41
41
 
42
+ // ── Per-execution logger context ─────────────────────────────────────────────
43
+
44
+ // Holds an AsyncLocalStorage instance once it is lazily initialised.
45
+ // Allows per-execution logger isolation without mutating the global singleton,
46
+ // making concurrent test execution (e.g. Deno's node:test) safe.
47
+ let _loggerStore = null
48
+
49
+ // Promise singleton — ensures AsyncLocalStorage is initialised at most once.
50
+ let _loggerStorePromise = null
51
+
52
+ /**
53
+ * Lazily initialise an AsyncLocalStorage for per-execution logger context.
54
+ * Falls back to null in environments that do not support node:async_hooks (e.g. browsers).
55
+ * @returns {Promise<import('node:async_hooks').AsyncLocalStorage|null>}
56
+ */
57
+ async function _ensureLoggerStore() {
58
+ if (_loggerStorePromise === null) {
59
+ _loggerStorePromise = import('node:async_hooks')
60
+ .then(({ AsyncLocalStorage }) => {
61
+ const store = new AsyncLocalStorage()
62
+ _loggerStore = store
63
+ return store
64
+ })
65
+ .catch(() => null)
66
+ }
67
+ return _loggerStorePromise
68
+ }
69
+
70
+ /** @internal — returns the logger bound to the current async context, or null */
71
+ export function getContextLogger() {
72
+ return _loggerStore?.getStore() ?? null
73
+ }
74
+
75
+ /**
76
+ * Run fn() within an async-local logger context so that all log calls via
77
+ * `this.logger` (from applyLogging) automatically route to the provided logger
78
+ * for the duration of the async execution chain.
79
+ *
80
+ * Falls back to global mutation in environments without node:async_hooks (e.g. browsers).
81
+ *
82
+ * @param {Logger|MemoryLogger|NullLogger} logger - The logger to activate.
83
+ * @param {() => any} fn - The function to execute within the logger context.
84
+ * @returns {Promise<any>}
85
+ */
86
+ export async function withLogger(logger, fn) {
87
+ const store = await _ensureLoggerStore()
88
+ if (store) {
89
+ return store.run(logger, fn)
90
+ }
91
+ // Fallback for environments without node:async_hooks (browsers).
92
+ const prev = LoggerManager.logger
93
+ if (logger !== prev) LoggerManager.logger = logger
94
+ try {
95
+ return await fn()
96
+ } finally {
97
+ if (logger !== prev) LoggerManager.logger = prev
98
+ }
99
+ }
100
+
42
101
  // ── Logger ────────────────────────────────────────────────────────────────────
43
102
 
44
103
  /** Standard logger that writes formatted messages to stderr or a custom pipe. */
@@ -347,8 +406,9 @@ export class MemoryLogger {
347
406
  // ── NullLogger ────────────────────────────────────────────────────────────────
348
407
 
349
408
  /** Logger that discards all messages but still tracks the maximum severity. */
350
- export class NullLogger {
409
+ export class NullLogger extends Logger {
351
410
  constructor() {
411
+ super()
352
412
  this.level = Severity.UNKNOWN
353
413
  this._maxSeverity = null
354
414
  }
@@ -493,12 +553,12 @@ export const LoggerManager = (() => {
493
553
  export function applyLogging(proto) {
494
554
  Object.defineProperty(proto, 'logger', {
495
555
  get() {
496
- return LoggerManager.logger
556
+ return _loggerStore?.getStore() ?? LoggerManager.logger
497
557
  },
498
558
  configurable: true,
499
559
  })
500
560
 
501
- proto.getLogger = () => LoggerManager.logger
561
+ proto.getLogger = () => _loggerStore?.getStore() ?? LoggerManager.logger
502
562
 
503
563
  proto.messageWithContext = (text, context = {}) =>
504
564
  Logger.AutoFormattingMessage.attach({ text, ...context })
@@ -512,10 +572,10 @@ export function applyLogging(proto) {
512
572
  */
513
573
  export const Logging = {
514
574
  get logger() {
515
- return LoggerManager.logger
575
+ return _loggerStore?.getStore() ?? LoggerManager.logger
516
576
  },
517
577
  getLogger() {
518
- return LoggerManager.logger
578
+ return _loggerStore?.getStore() ?? LoggerManager.logger
519
579
  },
520
580
  messageWithContext(text, context = {}) {
521
581
  return Logger.AutoFormattingMessage.attach({ text, ...context })
package/src/parser.js CHANGED
@@ -1549,7 +1549,7 @@ export class Parser {
1549
1549
  const Rdr = Reader
1550
1550
  const result = await extension.processMethod(
1551
1551
  parent,
1552
- blockReader ?? new Rdr(lines),
1552
+ blockReader ?? new Rdr(lines, null, { document: parent.document }),
1553
1553
  { ...attributes }
1554
1554
  )
1555
1555
  if (!result || result === parent) return null
package/src/reader.js CHANGED
@@ -661,7 +661,7 @@ export class Reader {
661
661
  return this.source()
662
662
  }
663
663
  getLogger() {
664
- return LoggerManager.logger
664
+ return this._document?.logger ?? LoggerManager.logger
665
665
  }
666
666
  createLogMessage(text, context = {}) {
667
667
  return Logger.AutoFormattingMessage.attach({ text, ...context })
@@ -201,7 +201,7 @@ export abstract class AbstractBlock<TContent extends string | any[] = string> ex
201
201
  * - `'reject'` → skip the node and its children
202
202
  * - `'stop'` → include the node (if it matched) and stop the entire traversal
203
203
  *
204
- * @param {Object} [selector={}] - Selector criteria object.
204
+ * @param {Object|Function} [selector={}] - Selector criteria object, or a filter callback when called as `findBy(callback)`.
205
205
  * @param {Function|null} [filter=null] - Per-node filter callback.
206
206
  * @returns {AbstractBlock[]} array of matching block-level nodes.
207
207
  *
@@ -216,8 +216,11 @@ export abstract class AbstractBlock<TContent extends string | any[] = string> ex
216
216
  *
217
217
  * @example <caption>All image blocks including those inside AsciiDoc table cells</caption>
218
218
  * const images = doc.findBy({ context: 'image', traverseDocuments: true })
219
+ *
220
+ * @example <caption>Filter-only shorthand (no selector)</caption>
221
+ * const verbatim = doc.findBy((b) => b.contentModel === ContentModel.VERBATIM)
219
222
  */
220
- findBy(selector?: any, filter?: Function | null): AbstractBlock[];
223
+ findBy(selector?: any | Function, filter?: Function | null): AbstractBlock[];
221
224
  /** Alias for {@link findBy}. */
222
225
  query(selector?: {}, filter?: any): AbstractBlock<string>[];
223
226
  /**
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Return the attribute entries stored for the given block attributes object,
3
+ * or undefined if none have been saved.
4
+ * @param {Object} blockAttributes
5
+ * @returns {AttributeEntry[]|undefined}
6
+ */
7
+ export function getAttributeEntries(blockAttributes: any): AttributeEntry[] | undefined;
8
+ export const ATTR_ENTRIES_KEY: unique symbol;
1
9
  export class AttributeEntry {
2
10
  constructor(name: any, value: any, negate?: any);
3
11
  name: any;
@@ -7,7 +7,7 @@
7
7
  * 1. target starts with file:// → inc_path = relpath = target
8
8
  * 2. target is a URI → must descend from baseDir or allow-uri-read; else → link
9
9
  * 3. target is an absolute OS path → prepend file:// (or file:///)
10
- * 4. baseDir == '.' → inc_path = relpath = target (resolved by XMLHttpRequest/fetch)
10
+ * 4. baseDir == '.' → inc_path = relpath = target (resolved by fetch)
11
11
  * 5. baseDir starts with file:// OR baseDir is not a URI → inc_path = baseDir/target; relpath = target
12
12
  * 6. baseDir is an absolute URL → inc_path = baseDir/target; relpath = target
13
13
  *
@@ -224,7 +224,12 @@ export class Processor {
224
224
  * Extensions.register(function () { this.preprocessor(CommentStripPreprocessor) })
225
225
  */
226
226
  export class Preprocessor extends Processor {
227
- process(_document: any, _reader: any): void;
227
+ /**
228
+ * @param {Document} document - The document being parsed.
229
+ * @param {Reader} reader - The reader positioned at the beginning of the source.
230
+ * @returns {Reader|undefined} The same or a substitute Reader, or undefined to use the original.
231
+ */
232
+ process(document: Document, reader: Reader): Reader | undefined;
228
233
  }
229
234
  export namespace Preprocessor {
230
235
  export { DocumentProcessorDsl as DSL };
@@ -246,7 +251,11 @@ export namespace Preprocessor {
246
251
  * Extensions.register(function () { this.treeProcessor(ShoutTreeProcessor) })
247
252
  */
248
253
  export class TreeProcessor extends Processor {
249
- process(_document: any): void;
254
+ /**
255
+ * @param {Document} document - The parsed document.
256
+ * @returns {void}
257
+ */
258
+ process(document: Document): void;
250
259
  }
251
260
  export namespace TreeProcessor {
252
261
  export { DocumentProcessorDsl as DSL };
@@ -271,7 +280,12 @@ export const Treeprocessor: typeof TreeProcessor;
271
280
  * Extensions.register(function () { this.postprocessor(FooterPostprocessor) })
272
281
  */
273
282
  export class Postprocessor extends Processor {
274
- process(_document: any, _output: any): void;
283
+ /**
284
+ * @param {Document} document - The converted document.
285
+ * @param {string} output - The converted output string.
286
+ * @returns {string} The (possibly modified) output string.
287
+ */
288
+ process(document: Document, output: string): string;
275
289
  }
276
290
  export namespace Postprocessor {
277
291
  export { DocumentProcessorDsl as DSL };
@@ -282,8 +296,20 @@ export namespace Postprocessor {
282
296
  * Implementations must extend IncludeProcessor.
283
297
  */
284
298
  export class IncludeProcessor extends Processor {
285
- process(_document: any, _reader: any, _target: any, _attributes: any): void;
286
- handles(_doc: any, _target: any): boolean;
299
+ /**
300
+ * @param {Document} document - The document being parsed.
301
+ * @param {Reader} reader - The reader for the including document.
302
+ * @param {string} target - The target of the include directive.
303
+ * @param {Record<string, string>} attributes - The parsed include attributes.
304
+ * @returns {void}
305
+ */
306
+ process(document: Document, reader: Reader, target: string, attributes: Record<string, string>): void;
307
+ /**
308
+ * @param {Document} doc - The document being parsed.
309
+ * @param {string} target - The target of the include directive.
310
+ * @returns {boolean} true if this processor handles the given target.
311
+ */
312
+ handles(doc: Document, target: string): boolean;
287
313
  }
288
314
  export namespace IncludeProcessor {
289
315
  export { IncludeProcessorDsl as DSL };
@@ -295,7 +321,11 @@ export namespace IncludeProcessor {
295
321
  * Implementations must extend DocinfoProcessor.
296
322
  */
297
323
  export class DocinfoProcessor extends Processor {
298
- process(_document: any): void;
324
+ /**
325
+ * @param {Document} document - The document being converted.
326
+ * @returns {string} The docinfo content to inject into the document.
327
+ */
328
+ process(document: Document): string;
299
329
  }
300
330
  export namespace DocinfoProcessor {
301
331
  export { DocinfoProcessorDsl as DSL };
@@ -331,7 +361,13 @@ export namespace DocinfoProcessor {
331
361
  export class BlockProcessor extends Processor {
332
362
  constructor(name?: any, config?: {});
333
363
  name: any;
334
- process(_parent: any, _reader: any, _attributes: any): void;
364
+ /**
365
+ * @param {AbstractBlock} parent - The enclosing block.
366
+ * @param {Reader} reader - The reader positioned at the block content.
367
+ * @param {Record<string, unknown>} attributes - The parsed block attributes.
368
+ * @returns {Block|void} A block node, or void to let the parser handle it.
369
+ */
370
+ process(parent: AbstractBlock, reader: Reader, attributes: Record<string, unknown>): Block | void;
335
371
  }
336
372
  export namespace BlockProcessor {
337
373
  export { BlockProcessorDsl as DSL };
@@ -342,7 +378,13 @@ export namespace BlockProcessor {
342
378
  export class MacroProcessor extends Processor {
343
379
  constructor(name?: any, config?: {});
344
380
  name: any;
345
- process(_parent: any, _target: any, _attributes: any): void;
381
+ /**
382
+ * @param {AbstractBlock} parent - The enclosing block.
383
+ * @param {string} target - The macro target (text between `name:` and `[`).
384
+ * @param {Record<string, unknown>} attributes - The parsed macro attributes.
385
+ * @returns {Block|Inline|void}
386
+ */
387
+ process(parent: AbstractBlock, target: string, attributes: Record<string, unknown>): Block | Inline | void;
346
388
  }
347
389
  /**
348
390
  * BlockMacroProcessors handle block macros with a custom name.
@@ -370,6 +412,13 @@ export class MacroProcessor extends Processor {
370
412
  */
371
413
  export class BlockMacroProcessor extends MacroProcessor {
372
414
  _name: any;
415
+ /**
416
+ * @param {AbstractBlock} parent - The enclosing block.
417
+ * @param {string} target - The macro target.
418
+ * @param {Record<string, unknown>} attributes - The parsed macro attributes.
419
+ * @returns {Block} A block node created with one of the `createBlock` helpers.
420
+ */
421
+ process(parent: AbstractBlock, target: string, attributes: Record<string, unknown>): Block;
373
422
  }
374
423
  export namespace BlockMacroProcessor {
375
424
  export { MacroProcessorDsl as DSL };
@@ -407,6 +456,13 @@ export class InlineMacroProcessor extends MacroProcessor {
407
456
  * @returns {RegExp}
408
457
  */
409
458
  get regexp(): RegExp;
459
+ /**
460
+ * @param {AbstractBlock} parent - The enclosing block.
461
+ * @param {string} target - The macro target.
462
+ * @param {Record<string, unknown>} attributes - The parsed macro attributes.
463
+ * @returns {Inline} An Inline node created with `this.createInline(...)`.
464
+ */
465
+ process(parent: AbstractBlock, target: string, attributes: Record<string, unknown>): Inline;
410
466
  resolveRegexp(name: any, format: any): any;
411
467
  }
412
468
  export namespace InlineMacroProcessor {
@@ -456,7 +512,7 @@ export class Registry {
456
512
  * @returns {Registry} this Registry.
457
513
  */
458
514
  activate(document: Document): Registry;
459
- document: any;
515
+ document: import("./document.js").Document;
460
516
  /**
461
517
  * Register a Preprocessor with the extension registry.
462
518
  *
@@ -609,6 +665,12 @@ export class Registry {
609
665
  * @returns {boolean}
610
666
  */
611
667
  hasBlocks(): boolean;
668
+ /**
669
+ * Retrieve all BlockProcessor Extension proxy objects.
670
+ *
671
+ * @returns {ProcessorExtension[]}
672
+ */
673
+ blocks(): ProcessorExtension[];
612
674
  /**
613
675
  * Check whether a BlockProcessor is registered for the given name and context.
614
676
  *
@@ -639,6 +701,12 @@ export class Registry {
639
701
  * @returns {boolean}
640
702
  */
641
703
  hasBlockMacros(): boolean;
704
+ /**
705
+ * Retrieve all BlockMacroProcessor Extension proxy objects.
706
+ *
707
+ * @returns {ProcessorExtension[]}
708
+ */
709
+ blockMacros(): ProcessorExtension[];
642
710
  /**
643
711
  * Check whether a BlockMacroProcessor is registered for the given name.
644
712
  *
@@ -700,6 +768,47 @@ export class Registry {
700
768
  * @returns {ProcessorExtension} the Extension stored in the registry.
701
769
  */
702
770
  prefer(...args: any[]): ProcessorExtension;
771
+ /** @returns {object} the plain Object that maps names to groups for this registry. */
772
+ getGroups(): object;
773
+ /** Alias for {@link preprocessors}. */
774
+ getPreprocessors(): ProcessorExtension[];
775
+ /** Alias for {@link treeProcessors}. */
776
+ getTreeProcessors(): ProcessorExtension[];
777
+ /** Alias for {@link includeProcessors}. */
778
+ getIncludeProcessors(): ProcessorExtension[];
779
+ /** Alias for {@link postprocessors}. */
780
+ getPostprocessors(): ProcessorExtension[];
781
+ /**
782
+ * Alias for {@link docinfoProcessors}.
783
+ *
784
+ * @param {string|null} [location=null]
785
+ */
786
+ getDocinfoProcessors(location?: string | null): ProcessorExtension[];
787
+ /** Alias for {@link blocks}. */
788
+ getBlocks(): ProcessorExtension[];
789
+ /** Alias for {@link blockMacros}. */
790
+ getBlockMacros(): ProcessorExtension[];
791
+ /** Alias for {@link inlineMacros}. */
792
+ getInlineMacros(): ProcessorExtension[];
793
+ /**
794
+ * Alias for {@link registeredForInlineMacro}.
795
+ *
796
+ * @param {string} name
797
+ */
798
+ getInlineMacroFor(name: string): false | ProcessorExtension;
799
+ /**
800
+ * Alias for {@link registeredForBlock}.
801
+ *
802
+ * @param {string} name
803
+ * @param {string} context
804
+ */
805
+ getBlockFor(name: string, context: string): false | ProcessorExtension;
806
+ /**
807
+ * Alias for {@link registeredForBlockMacro}.
808
+ *
809
+ * @param {string} name
810
+ */
811
+ getBlockMacroFor(name: string): false | ProcessorExtension;
703
812
  }
704
813
  export namespace Extensions {
705
814
  /**
@@ -708,6 +817,12 @@ export namespace Extensions {
708
817
  * @returns {object}
709
818
  */
710
819
  function groups(): object;
820
+ /**
821
+ * Alias for {@link groups}.
822
+ *
823
+ * @returns {object}
824
+ */
825
+ function getGroups(): object;
711
826
  /**
712
827
  * Create a new Registry, optionally pre-populated with a named block.
713
828
  *
@@ -868,6 +983,85 @@ export namespace Extensions {
868
983
  */
869
984
  function newBlockMacroProcessor(name?: string, functions?: object, ...args: any[]): BlockMacroProcessor;
870
985
  }
986
+ export type Document = import("./document.js").Document;
987
+ export type AbstractBlock = import("./abstract_block.js").AbstractBlock;
988
+ /**
989
+ * DSL interface for configuring a {@link Processor} instance.
990
+ * Applied to a processor instance via `Object.assign(instance, DslMixin)`.
991
+ *
992
+ * The `process` property behaves as a setter when called with a single Function
993
+ * argument (stores the process block), or as a passthrough caller otherwise.
994
+ */
995
+ export type ProcessorDslInterface = {
996
+ /**
997
+ * - Set a config option.
998
+ */
999
+ option: (key: string, value: unknown) => void;
1000
+ /**
1001
+ * - Register the process function.
1002
+ */
1003
+ process: (fn: (...args: unknown[]) => unknown) => void;
1004
+ /**
1005
+ * - Returns true if a process function has been registered.
1006
+ */
1007
+ processBlockGiven: () => boolean;
1008
+ };
1009
+ /**
1010
+ * DSL interface for document processors (Preprocessor, TreeProcessor, Postprocessor, DocinfoProcessor).
1011
+ */
1012
+ export type DocumentProcessorDslInterface = ProcessorDslInterface & {
1013
+ prefer(): void;
1014
+ prepend(): void;
1015
+ };
1016
+ /**
1017
+ * DSL interface for syntax processors (BlockProcessor, BlockMacroProcessor, InlineMacroProcessor).
1018
+ */
1019
+ export type SyntaxProcessorDslInterface = ProcessorDslInterface & {
1020
+ named(value: string): void;
1021
+ contentModel(value: string): void;
1022
+ parseContentAs(value: string): void;
1023
+ positionalAttributes(...value: string[]): void;
1024
+ namePositionalAttributes(...value: string[]): void;
1025
+ positionalAttrs(...value: string[]): void;
1026
+ defaultAttributes(value: Record<string, string>): void;
1027
+ defaultAttrs(value: Record<string, string>): void;
1028
+ resolveAttributes(...args: unknown[]): void;
1029
+ resolvesAttributes(...args: unknown[]): void;
1030
+ };
1031
+ /**
1032
+ * DSL interface for include processors.
1033
+ */
1034
+ export type IncludeProcessorDslInterface = DocumentProcessorDslInterface & {
1035
+ handles(fn: (doc: Document, target: string) => boolean): void;
1036
+ };
1037
+ /**
1038
+ * DSL interface for docinfo processors.
1039
+ */
1040
+ export type DocinfoProcessorDslInterface = DocumentProcessorDslInterface & {
1041
+ atLocation(value: string): void;
1042
+ };
1043
+ /**
1044
+ * DSL interface for block processors.
1045
+ */
1046
+ export type BlockProcessorDslInterface = SyntaxProcessorDslInterface & {
1047
+ contexts(...value: (string | string[])[]): void;
1048
+ onContexts(...value: (string | string[])[]): void;
1049
+ onContext(...value: (string | string[])[]): void;
1050
+ bindTo(...value: (string | string[])[]): void;
1051
+ };
1052
+ /**
1053
+ * DSL interface for macro processors (block and inline macros).
1054
+ */
1055
+ export type MacroProcessorDslInterface = SyntaxProcessorDslInterface;
1056
+ /**
1057
+ * DSL interface for inline macro processors.
1058
+ */
1059
+ export type InlineMacroProcessorDslInterface = MacroProcessorDslInterface & {
1060
+ format(value: string): void;
1061
+ matchFormat(value: string): void;
1062
+ usingFormat(value: string): void;
1063
+ match(value: RegExp): void;
1064
+ };
871
1065
  import { Section } from './section.js';
872
1066
  import { Block } from './block.js';
873
1067
  import { List } from './list.js';
@@ -0,0 +1,83 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Get the version of Asciidoctor.js.
4
+ *
5
+ * @returns {string} - the version of Asciidoctor.js
6
+ */
7
+ export function getVersion(): string;
8
+ /**
9
+ * Get Asciidoctor core version number.
10
+ *
11
+ * @returns {string} - the version of Asciidoctor core (Ruby)
12
+ */
13
+ export function getCoreVersion(): string;
14
+ /**
15
+ * Parse the AsciiDoc source input into a Document.
16
+ *
17
+ * @param {string|string[]|Buffer} input - the AsciiDoc source as a String, String Array, or Buffer
18
+ * @param {Object} [options={}] - a plain object of options to control processing
19
+ * @returns {Promise<Document>} - the parsed Document
20
+ */
21
+ export function load(input: string | string[] | Buffer, options?: any): Promise<Document>;
22
+ /**
23
+ * Parse the contents of the AsciiDoc source file into a Document.
24
+ *
25
+ * @param {string} filename - the path to the AsciiDoc source file
26
+ * @param {Object} [options={}] - a plain object of options to control processing
27
+ * @returns {Promise<Document>} - the parsed Document
28
+ */
29
+ export function loadFile(filename: string, options?: any): Promise<Document>;
30
+ export type ProcessorDslInterface = import("./extensions.js").ProcessorDslInterface;
31
+ export type DocumentProcessorDslInterface = import("./extensions.js").DocumentProcessorDslInterface;
32
+ export type SyntaxProcessorDslInterface = import("./extensions.js").SyntaxProcessorDslInterface;
33
+ export type IncludeProcessorDslInterface = import("./extensions.js").IncludeProcessorDslInterface;
34
+ export type DocinfoProcessorDslInterface = import("./extensions.js").DocinfoProcessorDslInterface;
35
+ export type BlockProcessorDslInterface = import("./extensions.js").BlockProcessorDslInterface;
36
+ export type MacroProcessorDslInterface = import("./extensions.js").MacroProcessorDslInterface;
37
+ export type InlineMacroProcessorDslInterface = import("./extensions.js").InlineMacroProcessorDslInterface;
38
+ import { Document } from './document.js';
39
+ import { convert } from './convert.js';
40
+ import { convertFile } from './convert.js';
41
+ import { DocumentTitle } from './document.js';
42
+ import { Author } from './document.js';
43
+ import { Footnote } from './document.js';
44
+ import { ImageReference } from './document.js';
45
+ import { RevisionInfo } from './document.js';
46
+ import { Logger } from './logging.js';
47
+ import { AbstractNode } from './abstract_node.js';
48
+ import { AbstractBlock } from './abstract_block.js';
49
+ import { Inline } from './inline.js';
50
+ import { Block } from './block.js';
51
+ import { List } from './list.js';
52
+ import { ListItem } from './list.js';
53
+ import { Section } from './section.js';
54
+ import { Reader } from './reader.js';
55
+ import { SyntaxHighlighterBase } from './syntax_highlighter.js';
56
+ import { LoggerManager } from './logging.js';
57
+ import { MemoryLogger } from './logging.js';
58
+ import { NullLogger } from './logging.js';
59
+ import { SafeMode } from './constants.js';
60
+ import { ContentModel } from './constants.js';
61
+ import { Timings } from './timings.js';
62
+ import { Registry } from './extensions.js';
63
+ import { Processor } from './extensions.js';
64
+ import { ProcessorExtension } from './extensions.js';
65
+ import { Preprocessor } from './extensions.js';
66
+ import { TreeProcessor } from './extensions.js';
67
+ import { Postprocessor } from './extensions.js';
68
+ import { IncludeProcessor } from './extensions.js';
69
+ import { DocinfoProcessor } from './extensions.js';
70
+ import { BlockProcessor } from './extensions.js';
71
+ import { InlineMacroProcessor } from './extensions.js';
72
+ import { BlockMacroProcessor } from './extensions.js';
73
+ import { Extensions } from './extensions.js';
74
+ import { Cursor } from './reader.js';
75
+ import { Converter } from './converter.js';
76
+ import { ConverterBase } from './converter.js';
77
+ import { CustomFactory } from './converter.js';
78
+ import { DefaultFactory as DefaultConverterFactory } from './converter.js';
79
+ import { deriveBackendTraits } from './converter.js';
80
+ import { DefaultFactory as DefaultSyntaxHighlighterFactory } from './syntax_highlighter.js';
81
+ import Html5Converter from './converter/html5.js';
82
+ import { SyntaxHighlighter } from './syntax_highlighter.js';
83
+ export { convert, convertFile, Document, DocumentTitle, Author, Footnote, ImageReference, RevisionInfo, Logger, AbstractNode, AbstractBlock, Inline, Block, List, ListItem, Section, Reader, SyntaxHighlighterBase, LoggerManager, MemoryLogger, NullLogger, SafeMode, ContentModel, Timings, Registry, Processor, ProcessorExtension, Preprocessor, TreeProcessor, Postprocessor, IncludeProcessor, DocinfoProcessor, BlockProcessor, InlineMacroProcessor, BlockMacroProcessor, Extensions, Cursor, Converter as ConverterFactory, ConverterBase, CustomFactory as ConverterCustomFactory, DefaultConverterFactory, deriveBackendTraits, DefaultSyntaxHighlighterFactory, Html5Converter, SyntaxHighlighter };
package/types/index.d.ts CHANGED
@@ -26,6 +26,14 @@ export function load(input: string | string[] | Buffer, options?: any): Promise<
26
26
  * @returns {Promise<Document>} - the parsed Document
27
27
  */
28
28
  export function loadFile(filename: string, options?: any): Promise<Document>;
29
+ export type ProcessorDslInterface = import("./extensions.js").ProcessorDslInterface;
30
+ export type DocumentProcessorDslInterface = import("./extensions.js").DocumentProcessorDslInterface;
31
+ export type SyntaxProcessorDslInterface = import("./extensions.js").SyntaxProcessorDslInterface;
32
+ export type IncludeProcessorDslInterface = import("./extensions.js").IncludeProcessorDslInterface;
33
+ export type DocinfoProcessorDslInterface = import("./extensions.js").DocinfoProcessorDslInterface;
34
+ export type BlockProcessorDslInterface = import("./extensions.js").BlockProcessorDslInterface;
35
+ export type MacroProcessorDslInterface = import("./extensions.js").MacroProcessorDslInterface;
36
+ export type InlineMacroProcessorDslInterface = import("./extensions.js").InlineMacroProcessorDslInterface;
29
37
  import { Document } from './document.js';
30
38
  import { convert } from './convert.js';
31
39
  import { convertFile } from './convert.js';