@asciidoctor/core 4.0.0-alpha.2 → 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/build/browser/index.js +410 -34
- package/build/node/index.cjs +411 -35
- package/package.json +3 -2
- package/src/attribute_entry.js +17 -1
- package/src/browser/reader.js +2 -2
- package/src/converter/template.js +1 -1
- package/src/document.js +15 -4
- package/src/extensions.js +266 -8
- package/src/helpers.js +20 -2
- package/src/index.js +12 -0
- package/src/load.js +30 -13
- package/src/logging.js +65 -5
- package/src/parser.js +1 -1
- package/src/reader.js +1 -1
- package/types/attribute_entry.d.ts +8 -0
- package/types/browser/reader.d.ts +1 -1
- package/types/extensions.d.ts +203 -9
- package/types/index.d.cts +8 -0
- package/types/index.d.ts +8 -0
- package/types/logging.d.ts +15 -4
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 })
|
|
@@ -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
|
|
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
|
*
|
package/types/extensions.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
286
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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';
|
package/types/index.d.cts
CHANGED
|
@@ -27,6 +27,14 @@ export function load(input: string | string[] | Buffer, options?: any): Promise<
|
|
|
27
27
|
* @returns {Promise<Document>} - the parsed Document
|
|
28
28
|
*/
|
|
29
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;
|
|
30
38
|
import { Document } from './document.js';
|
|
31
39
|
import { convert } from './convert.js';
|
|
32
40
|
import { convertFile } from './convert.js';
|
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';
|
package/types/logging.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Run fn() within an async-local logger context so that all log calls via
|
|
4
|
+
* `this.logger` (from applyLogging) automatically route to the provided logger
|
|
5
|
+
* for the duration of the async execution chain.
|
|
6
|
+
*
|
|
7
|
+
* Falls back to global mutation in environments without node:async_hooks (e.g. browsers).
|
|
8
|
+
*
|
|
9
|
+
* @param {Logger|MemoryLogger|NullLogger} logger - The logger to activate.
|
|
10
|
+
* @param {() => any} fn - The function to execute within the logger context.
|
|
11
|
+
* @returns {Promise<any>}
|
|
12
|
+
*/
|
|
13
|
+
export function withLogger(logger: Logger | MemoryLogger | NullLogger, fn: () => any): Promise<any>;
|
|
1
14
|
/**
|
|
2
15
|
* Apply the Logging mixin to a class prototype.
|
|
3
16
|
*
|
|
@@ -120,12 +133,10 @@ export class MemoryLogger {
|
|
|
120
133
|
empty(): boolean;
|
|
121
134
|
}
|
|
122
135
|
/** Logger that discards all messages but still tracks the maximum severity. */
|
|
123
|
-
export class NullLogger {
|
|
136
|
+
export class NullLogger extends Logger {
|
|
124
137
|
static create(): NullLogger;
|
|
138
|
+
constructor();
|
|
125
139
|
level: number;
|
|
126
|
-
_maxSeverity: number;
|
|
127
|
-
get maxSeverity(): number;
|
|
128
|
-
getMaxSeverity(): number;
|
|
129
140
|
add(severity: any): boolean;
|
|
130
141
|
log(severity: any): boolean;
|
|
131
142
|
debug(): boolean;
|