@asciidoctor/core 4.0.0-alpha.6 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/browser/index.js +204 -57
- package/build/node/index.cjs +204 -56
- package/package.json +2 -2
- package/src/browser/reader.js +2 -2
- package/src/browser.js +8 -1
- package/src/document.js +15 -1
- package/src/extensions.js +125 -22
- package/src/index.js +8 -1
- package/src/logging.js +41 -10
- package/src/parser.js +13 -2
- package/src/reader.js +25 -13
- package/src/substitutors.js +9 -9
- package/types/extensions.d.ts +68 -6
- package/types/index.d.cts +2 -1
- package/types/index.d.ts +2 -1
- package/types/logging.d.ts +49 -5
- package/types/reader.d.ts +2 -2
- package/types/substitutors.d.ts +18 -18
package/types/logging.d.ts
CHANGED
|
@@ -95,22 +95,66 @@ export namespace Logger {
|
|
|
95
95
|
export { BasicFormatter };
|
|
96
96
|
export namespace AutoFormattingMessage {
|
|
97
97
|
/**
|
|
98
|
-
* Attach auto-formatting to any plain object carrying
|
|
99
|
-
*
|
|
98
|
+
* Attach auto-formatting to any plain object carrying
|
|
99
|
+
* { text, source_location, include_location }.
|
|
100
|
+
*
|
|
101
|
+
* The location(s) are rendered only by inspect()/toString() (used when a
|
|
102
|
+
* stderr Logger formats the line); the structured `source_location` /
|
|
103
|
+
* `include_location` remain on the object so a MemoryLogger can record them
|
|
104
|
+
* on the resulting LogMessage without duplicating them inside `text`.
|
|
105
|
+
* @param {{text: string, source_location?: any, include_location?: any}} obj
|
|
100
106
|
* @returns {typeof obj} The same object with inspect() and toString() added.
|
|
101
107
|
*/
|
|
102
108
|
function attach(obj: {
|
|
103
109
|
text: string;
|
|
104
|
-
source_location?:
|
|
110
|
+
source_location?: any;
|
|
111
|
+
include_location?: any;
|
|
105
112
|
}): typeof obj;
|
|
106
113
|
}
|
|
107
114
|
}
|
|
115
|
+
/** Wrapper stored by MemoryLogger; provides getSeverity/getText/getSourceLocation. */
|
|
116
|
+
export class LogMessage {
|
|
117
|
+
/**
|
|
118
|
+
* @param {string} severity - Severity label, e.g. 'ERROR'.
|
|
119
|
+
* @param {string|{text: string, source_location?: import('./reader.js').Cursor}|null} message
|
|
120
|
+
*/
|
|
121
|
+
constructor(severity: string, message: string | {
|
|
122
|
+
text: string;
|
|
123
|
+
source_location?: import("./reader.js").Cursor;
|
|
124
|
+
} | null);
|
|
125
|
+
message: string | {
|
|
126
|
+
text: string;
|
|
127
|
+
source_location?: import("./reader.js").Cursor;
|
|
128
|
+
};
|
|
129
|
+
/** @type {string} */
|
|
130
|
+
severity: string;
|
|
131
|
+
/** @type {string} */
|
|
132
|
+
text: string;
|
|
133
|
+
/** @type {import('./reader.js').Cursor|null} */
|
|
134
|
+
sourceLocation: import("./reader.js").Cursor | null;
|
|
135
|
+
/**
|
|
136
|
+
* @returns {string} The severity label, e.g. 'ERROR'.
|
|
137
|
+
*/
|
|
138
|
+
getSeverity(): string;
|
|
139
|
+
/**
|
|
140
|
+
* @returns {string} The message text.
|
|
141
|
+
*/
|
|
142
|
+
getText(): string;
|
|
143
|
+
/**
|
|
144
|
+
* @returns {import('./reader.js').Cursor|undefined} The source location, if any.
|
|
145
|
+
*/
|
|
146
|
+
getSourceLocation(): import("./reader.js").Cursor | undefined;
|
|
147
|
+
}
|
|
108
148
|
/** In-memory logger that stores all log messages for later inspection. */
|
|
109
149
|
export class MemoryLogger {
|
|
110
150
|
static create(): MemoryLogger;
|
|
111
151
|
level: number;
|
|
112
|
-
|
|
113
|
-
|
|
152
|
+
/** @type {LogMessage[]} */
|
|
153
|
+
messages: LogMessage[];
|
|
154
|
+
/**
|
|
155
|
+
* @returns {LogMessage[]} The log messages recorded so far, in order.
|
|
156
|
+
*/
|
|
157
|
+
getMessages(): LogMessage[];
|
|
114
158
|
getMaxSeverity(): number;
|
|
115
159
|
add(severity: any, message?: any, progname?: any): boolean;
|
|
116
160
|
debug(msg: any, pn: any): boolean;
|
package/types/reader.d.ts
CHANGED
|
@@ -123,13 +123,13 @@ export class Reader {
|
|
|
123
123
|
createLogMessage(text: any, context?: {}): any;
|
|
124
124
|
get logger(): any;
|
|
125
125
|
/** @param {string} msg @param {{ sourceLocation?: any, includeLocation?: any }} [opts] */
|
|
126
|
-
_logWarn(msg: string,
|
|
126
|
+
_logWarn(msg: string, opts?: {
|
|
127
127
|
sourceLocation?: any;
|
|
128
128
|
includeLocation?: any;
|
|
129
129
|
}): void;
|
|
130
130
|
_logError(msg: any, opts?: {}): void;
|
|
131
131
|
/** @param {string} msg @param {{ sourceLocation?: any }} [opts] */
|
|
132
|
-
_logInfo(msg: string,
|
|
132
|
+
_logInfo(msg: string, opts?: {
|
|
133
133
|
sourceLocation?: any;
|
|
134
134
|
}): void;
|
|
135
135
|
}
|
package/types/substitutors.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export namespace Substitutors {
|
|
|
4
4
|
*
|
|
5
5
|
* @param {string|string[]} text - The text to process; must not be null.
|
|
6
6
|
* @param {string[]} [subs=NORMAL_SUBS] - The substitutions to perform.
|
|
7
|
-
* @returns {string|string[]} Text with substitutions applied.
|
|
7
|
+
* @returns {Promise<string|string[]>} Text with substitutions applied.
|
|
8
8
|
*/
|
|
9
|
-
function applySubs(text: string | string[], subs?: string[]): string | string[]
|
|
9
|
+
function applySubs(text: string | string[], subs?: string[]): Promise<string | string[]>;
|
|
10
10
|
/** Apply normal substitutions (alias for applySubs with default args). */
|
|
11
11
|
function applyNormalSubs(text: any): Promise<string | string[]>;
|
|
12
12
|
/** Apply substitutions for header metadata and attribute assignments.
|
|
@@ -32,9 +32,9 @@ export namespace Substitutors {
|
|
|
32
32
|
* Substitute quoted text (emphasis, strong, monospaced, etc.)
|
|
33
33
|
*
|
|
34
34
|
* @param {string} text
|
|
35
|
-
* @returns {string}
|
|
35
|
+
* @returns {Promise<string>}
|
|
36
36
|
*/
|
|
37
|
-
function subQuotes(text: string): string
|
|
37
|
+
function subQuotes(text: string): Promise<string>;
|
|
38
38
|
/**
|
|
39
39
|
* Substitute attribute references in the specified text.
|
|
40
40
|
*
|
|
@@ -54,39 +54,39 @@ export namespace Substitutors {
|
|
|
54
54
|
* Substitute inline macros (links, images, etc.)
|
|
55
55
|
*
|
|
56
56
|
* @param {string} text
|
|
57
|
-
* @returns {string}
|
|
57
|
+
* @returns {Promise<string>}
|
|
58
58
|
*/
|
|
59
|
-
function subMacros(text: string): string
|
|
59
|
+
function subMacros(text: string): Promise<string>;
|
|
60
60
|
/**
|
|
61
61
|
* Substitute post replacements (hard line breaks).
|
|
62
62
|
*
|
|
63
63
|
* @param {string} text
|
|
64
|
-
* @returns {string}
|
|
64
|
+
* @returns {Promise<string>}
|
|
65
65
|
*/
|
|
66
|
-
function subPostReplacements(text: string): string
|
|
66
|
+
function subPostReplacements(text: string): Promise<string>;
|
|
67
67
|
/**
|
|
68
68
|
* Apply verbatim substitutions on source.
|
|
69
69
|
*
|
|
70
70
|
* @param {string} source
|
|
71
71
|
* @param {boolean} processCallouts
|
|
72
|
-
* @returns {string}
|
|
72
|
+
* @returns {Promise<string>}
|
|
73
73
|
*/
|
|
74
|
-
function subSource(source: string, processCallouts: boolean): string
|
|
74
|
+
function subSource(source: string, processCallouts: boolean): Promise<string>;
|
|
75
75
|
/**
|
|
76
76
|
* Substitute callout source references.
|
|
77
77
|
*
|
|
78
78
|
* @param {string} text
|
|
79
|
-
* @returns {string}
|
|
79
|
+
* @returns {Promise<string>}
|
|
80
80
|
*/
|
|
81
|
-
function subCallouts(text: string): string
|
|
81
|
+
function subCallouts(text: string): Promise<string>;
|
|
82
82
|
/**
|
|
83
83
|
* Highlight (colorize) the source code using a syntax highlighter.
|
|
84
84
|
*
|
|
85
85
|
* @param {string} source
|
|
86
86
|
* @param {boolean} processCallouts
|
|
87
|
-
* @returns {string}
|
|
87
|
+
* @returns {Promise<string>}
|
|
88
88
|
*/
|
|
89
|
-
function highlightSource(source: string, processCallouts: boolean): string
|
|
89
|
+
function highlightSource(source: string, processCallouts: boolean): Promise<string>;
|
|
90
90
|
/**
|
|
91
91
|
* Resolve line numbers to highlight from a test string.
|
|
92
92
|
*
|
|
@@ -107,9 +107,9 @@ export namespace Substitutors {
|
|
|
107
107
|
* Restore passthrough text by reinserting into placeholder positions.
|
|
108
108
|
*
|
|
109
109
|
* @param {string} text
|
|
110
|
-
* @returns {string}
|
|
110
|
+
* @returns {Promise<string>}
|
|
111
111
|
*/
|
|
112
|
-
function restorePassthroughs(text: string): string
|
|
112
|
+
function restorePassthroughs(text: string): Promise<string>;
|
|
113
113
|
/**
|
|
114
114
|
* Resolve the list of comma-delimited subs against the possible options.
|
|
115
115
|
*
|
|
@@ -143,9 +143,9 @@ export namespace Substitutors {
|
|
|
143
143
|
* @param {string} attrlist
|
|
144
144
|
* @param {string[]} [posattrs=[]]
|
|
145
145
|
* @param {Object} [opts={}]
|
|
146
|
-
* @returns {Object}
|
|
146
|
+
* @returns {Promise<Object>}
|
|
147
147
|
*/
|
|
148
|
-
function parseAttributes(attrlist: string, posattrs?: string[], opts?: any): any
|
|
148
|
+
function parseAttributes(attrlist: string, posattrs?: string[], opts?: any): Promise<any>;
|
|
149
149
|
function extractAttributesFromText(text: any, defaultText?: any): Promise<any[]>;
|
|
150
150
|
function extractCallouts(source: any): any[];
|
|
151
151
|
function restoreCallouts(source: any, calloutMarks: any, sourceOffset?: any): Promise<string>;
|