@asciidoctor/core 3.0.4 → 4.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -10
- package/build/browser/index.js +24156 -0
- package/build/node/index.cjs +24737 -0
- package/{dist/css/asciidoctor.css → data/asciidoctor-default.css} +54 -53
- package/package.json +55 -97
- package/src/abstract_block.js +857 -0
- package/src/abstract_node.js +954 -0
- package/src/attribute_entry.js +12 -0
- package/src/attribute_list.js +380 -0
- package/src/block.js +168 -0
- package/src/browser/asset.js +22 -0
- package/src/browser/reader.js +138 -0
- package/src/browser.js +121 -0
- package/src/callouts.js +85 -0
- package/src/compliance.js +54 -0
- package/src/constants.js +665 -0
- package/src/convert.js +370 -0
- package/src/converter/composite.js +83 -0
- package/src/converter/docbook5.js +1031 -0
- package/src/converter/html5.js +1893 -0
- package/src/converter/manpage.js +935 -0
- package/src/converter/template.js +459 -0
- package/src/converter.js +478 -0
- package/src/data/stylesheet-data.js +2 -0
- package/src/document.js +2134 -0
- package/src/extensions.js +1952 -0
- package/src/footnote.js +28 -0
- package/src/helpers.js +355 -0
- package/src/index.js +138 -0
- package/src/inline.js +158 -0
- package/src/list.js +240 -0
- package/src/load.js +276 -0
- package/src/logging.js +526 -0
- package/src/parser.js +3661 -0
- package/src/path_resolver.js +472 -0
- package/src/reader.js +1755 -0
- package/src/rx.js +829 -0
- package/src/section.js +354 -0
- package/src/stylesheets.js +30 -0
- package/src/substitutors.js +2241 -0
- package/src/syntaxHighlighter/highlightjs.js +90 -0
- package/src/syntaxHighlighter/html_pipeline.js +33 -0
- package/src/syntax_highlighter.js +304 -0
- package/src/table.js +952 -0
- package/src/timings.js +78 -0
- package/types/abstract_block.d.ts +346 -0
- package/types/abstract_node.d.ts +471 -0
- package/types/attribute_entry.d.ts +7 -0
- package/types/attribute_list.d.ts +52 -0
- package/types/block.d.ts +55 -0
- package/types/browser/asset.d.ts +7 -0
- package/types/browser/reader.d.ts +29 -0
- package/types/callouts.d.ts +36 -0
- package/types/compliance.d.ts +23 -0
- package/types/constants.d.ts +268 -0
- package/types/convert.d.ts +34 -0
- package/types/converter/composite.d.ts +20 -0
- package/types/converter/docbook5.d.ts +41 -0
- package/types/converter/html5.d.ts +51 -0
- package/types/converter/manpage.d.ts +59 -0
- package/types/converter/template.d.ts +83 -0
- package/types/converter.d.ts +150 -0
- package/types/data/stylesheet-data.d.ts +2 -0
- package/types/document.d.ts +495 -0
- package/types/extensions.d.ts +876 -0
- package/types/footnote.d.ts +18 -0
- package/types/helpers.d.ts +146 -0
- package/types/index.d.cts +75 -0
- package/types/index.d.ts +73 -3731
- package/types/inline.d.ts +69 -0
- package/types/list.d.ts +114 -0
- package/types/load.d.ts +39 -0
- package/types/logging.d.ts +187 -0
- package/types/parser.d.ts +114 -0
- package/types/path_resolver.d.ts +103 -0
- package/types/reader.d.ts +184 -0
- package/types/rx.d.ts +513 -0
- package/types/section.d.ts +122 -0
- package/types/stylesheets.d.ts +10 -0
- package/types/substitutors.d.ts +208 -0
- package/types/syntaxHighlighter/highlightjs.d.ts +33 -0
- package/types/syntaxHighlighter/html_pipeline.d.ts +16 -0
- package/types/syntax_highlighter.d.ts +167 -0
- package/types/table.d.ts +231 -0
- package/types/timings.d.ts +25 -0
- package/types/tsconfig.json +9 -0
- package/LICENSE +0 -21
- package/dist/browser/asciidoctor.js +0 -47654
- package/dist/browser/asciidoctor.min.js +0 -1452
- package/dist/graalvm/asciidoctor.js +0 -47402
- package/dist/node/asciidoctor.cjs +0 -21567
- package/dist/node/asciidoctor.js +0 -23037
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an inline element in an AsciiDoc document.
|
|
3
|
+
*/
|
|
4
|
+
export class Inline extends AbstractNode {
|
|
5
|
+
/**
|
|
6
|
+
* @param {AbstractNode} parent
|
|
7
|
+
* @param {string} context
|
|
8
|
+
* @param {string|null} [text=null] - The String text of this inline element.
|
|
9
|
+
* @param {Object} [opts={}] - A plain object of options:
|
|
10
|
+
* id - The String id of this inline element.
|
|
11
|
+
* type - The String type qualifier (e.g. 'ref', 'bibref').
|
|
12
|
+
* target - The String target (e.g. a URI).
|
|
13
|
+
*/
|
|
14
|
+
constructor(parent: AbstractNode, context: string, text?: string | null, opts?: any);
|
|
15
|
+
/** @type {string|null} */
|
|
16
|
+
type: string | null;
|
|
17
|
+
/** @type {string|null} */
|
|
18
|
+
target: string | null;
|
|
19
|
+
/** @type {string|null} */
|
|
20
|
+
text: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Convert this inline element using the document's converter.
|
|
23
|
+
* @returns {Promise<string>}
|
|
24
|
+
*/
|
|
25
|
+
convert(): Promise<string>;
|
|
26
|
+
/** @deprecated Use convert() instead. */
|
|
27
|
+
render(): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Get the converted content (alias for text).
|
|
30
|
+
* @returns {string|null}
|
|
31
|
+
*/
|
|
32
|
+
content(): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Alias for {@link getAlt}.
|
|
35
|
+
* @see {getAlt}
|
|
36
|
+
*/
|
|
37
|
+
get alt(): any;
|
|
38
|
+
/**
|
|
39
|
+
* Generate cross-reference text (xreftext) that can be used to refer to this inline node.
|
|
40
|
+
*
|
|
41
|
+
* Uses the explicit reftext for this inline node, if specified, retrieved by calling the
|
|
42
|
+
* reftext method. Otherwise, returns null.
|
|
43
|
+
*
|
|
44
|
+
* @param {string|null} [_xrefstyle=null] - Not currently used.
|
|
45
|
+
* @returns {string|null} the reftext to refer to this inline node, or null if no reftext is defined.
|
|
46
|
+
*/
|
|
47
|
+
xreftext(_xrefstyle?: string | null): string | null;
|
|
48
|
+
/**
|
|
49
|
+
* Return the text of this inline node.
|
|
50
|
+
* @returns {string|null}
|
|
51
|
+
*/
|
|
52
|
+
getText(): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Return the type qualifier of this inline node (e.g. 'ref', 'bibref').
|
|
55
|
+
* @returns {string|null}
|
|
56
|
+
*/
|
|
57
|
+
getType(): string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Return the target (e.g. URI or anchor) of this inline node.
|
|
60
|
+
* @returns {string|null}
|
|
61
|
+
*/
|
|
62
|
+
getTarget(): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Get the alt text for this inline image.
|
|
65
|
+
* @returns {string} the value of the alt attribute, or ''.
|
|
66
|
+
*/
|
|
67
|
+
getAlt(): string;
|
|
68
|
+
}
|
|
69
|
+
import { AbstractNode } from './abstract_node.js';
|
package/types/list.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @extends {AbstractBlock<any[]>}
|
|
3
|
+
*/
|
|
4
|
+
export class List extends AbstractBlock<any[]> {
|
|
5
|
+
constructor(parent: any, context: any, opts?: {});
|
|
6
|
+
/** Alias for blocks — the list content. */
|
|
7
|
+
content(): Promise<AbstractBlock<string>[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Alias for {@link getItems}.
|
|
10
|
+
* @returns {ListItem[]}
|
|
11
|
+
* @see {getItems}
|
|
12
|
+
*/
|
|
13
|
+
get items(): ListItem[];
|
|
14
|
+
/**
|
|
15
|
+
* Check whether this list has items (blocks).
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/
|
|
18
|
+
hasItems(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check whether this list is an outline list (unordered or ordered).
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
outline(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Return the list items.
|
|
26
|
+
* @returns {ListItem[]}
|
|
27
|
+
*/
|
|
28
|
+
getItems(): ListItem[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Methods for managing items for AsciiDoc olists, ulists, and dlists.
|
|
32
|
+
*
|
|
33
|
+
* In a description list (dlist), each item is a tuple: `[[term, term, ...], desc]`.
|
|
34
|
+
* If a description is not set, the second entry is null.
|
|
35
|
+
*/
|
|
36
|
+
export class ListItem extends AbstractBlock<string> {
|
|
37
|
+
/**
|
|
38
|
+
* @param {List} parent - The parent List block.
|
|
39
|
+
* @param {string|null} [text=null] - The text of this item.
|
|
40
|
+
*/
|
|
41
|
+
constructor(parent: List, text?: string | null);
|
|
42
|
+
/**
|
|
43
|
+
* The string marker used for this list item.
|
|
44
|
+
* @type {string|null}
|
|
45
|
+
*/
|
|
46
|
+
marker: string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Contextual alias for parent.
|
|
49
|
+
* @see {getParent}
|
|
50
|
+
*/
|
|
51
|
+
get list(): import("./abstract_node.js").AbstractNode;
|
|
52
|
+
/**
|
|
53
|
+
* Alias for {@link setText}.
|
|
54
|
+
* @see {setText}
|
|
55
|
+
*/
|
|
56
|
+
set text(val: any);
|
|
57
|
+
/**
|
|
58
|
+
* Alias for {@link getText}.
|
|
59
|
+
* @see {getText}
|
|
60
|
+
*/
|
|
61
|
+
get text(): any;
|
|
62
|
+
/**
|
|
63
|
+
* Check whether the text of this list item is non-blank.
|
|
64
|
+
* @returns {boolean}
|
|
65
|
+
*/
|
|
66
|
+
hasText(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Pre-compute the converted text asynchronously.
|
|
69
|
+
* Called during `Document.parse()` so the synchronous getter works during conversion.
|
|
70
|
+
* @returns {Promise<void>}
|
|
71
|
+
*/
|
|
72
|
+
precomputeText(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Check whether this list item has simple content.
|
|
75
|
+
* @returns {boolean} `true` if the item has no blocks or only a single nested outline list.
|
|
76
|
+
*/
|
|
77
|
+
simple(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Check whether this list item has compound content.
|
|
80
|
+
* @returns {boolean} `true` if the item contains blocks other than a single nested outline list.
|
|
81
|
+
*/
|
|
82
|
+
compound(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Return the parent List block (alias of {@link getParent}).
|
|
85
|
+
* @returns {List}
|
|
86
|
+
* @see {getParent}
|
|
87
|
+
*/
|
|
88
|
+
getList(): List;
|
|
89
|
+
/**
|
|
90
|
+
* Return the list marker string for this item (e.g. '.', '..', '*').
|
|
91
|
+
* @returns {string|null}
|
|
92
|
+
*/
|
|
93
|
+
getMarker(): string | null;
|
|
94
|
+
/**
|
|
95
|
+
* Return the text of this list item with substitutions applied.
|
|
96
|
+
* The result is pre-computed during `Document.parse()` via {@link precomputeText}.
|
|
97
|
+
* Falls back to the raw text if {@link precomputeText} has not been called yet.
|
|
98
|
+
*
|
|
99
|
+
* In Ruby, text is lazy (`apply_subs` on first access), so API callers can modify
|
|
100
|
+
* subs before accessing text and get the result they expect. Here we replicate
|
|
101
|
+
* that by invalidating the pre-computed value when subs have changed since it
|
|
102
|
+
* was computed: returning raw text mirrors what Ruby would produce when subs are
|
|
103
|
+
* cleared or reduced to a no-op set (since `applySubs` is async and cannot be
|
|
104
|
+
* re-run synchronously).
|
|
105
|
+
* @returns {string|null}
|
|
106
|
+
*/
|
|
107
|
+
getText(): string | null;
|
|
108
|
+
/**
|
|
109
|
+
* Set the raw text of this list item.
|
|
110
|
+
* @param {string|null} val
|
|
111
|
+
*/
|
|
112
|
+
setText(val: string | null): void;
|
|
113
|
+
}
|
|
114
|
+
import { AbstractBlock } from './abstract_block.js';
|
package/types/load.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse the AsciiDoc source input into a Document.
|
|
3
|
+
*
|
|
4
|
+
* Accepts input as a Node.js Readable stream (or any object with a read()
|
|
5
|
+
* method), a String, or a String Array. If the input is a file descriptor
|
|
6
|
+
* object produced by openFile() / Node's fs.openSync(), pass a plain object
|
|
7
|
+
* with { path, read() } instead; the function sets docfile/docdir/docname
|
|
8
|
+
* attributes automatically.
|
|
9
|
+
*
|
|
10
|
+
* @param {Buffer|string|string[]|{path?: string, read(): string|Promise<string>, mtime?: Date}} input - The AsciiDoc source.
|
|
11
|
+
* @param {Object} [options={}] - Options to control processing. See Document for the full list.
|
|
12
|
+
* @param {string|string[]|Object} [options.attributes] - Document attributes.
|
|
13
|
+
* @param {boolean} [options.parse] - Set to false to skip parsing after Document creation.
|
|
14
|
+
* @param {Object} [options.logger] - Logger instance to use for this call.
|
|
15
|
+
* @param {{start(label: string): void, record(label: string): void}} [options.timings] - Timings object.
|
|
16
|
+
* @returns {Promise<Document>} A Promise that resolves to the Document.
|
|
17
|
+
*/
|
|
18
|
+
export function load(input: Buffer | string | string[] | {
|
|
19
|
+
path?: string;
|
|
20
|
+
read(): string | Promise<string>;
|
|
21
|
+
mtime?: Date;
|
|
22
|
+
}, options?: {
|
|
23
|
+
attributes?: string | string[] | any;
|
|
24
|
+
parse?: boolean;
|
|
25
|
+
logger?: any;
|
|
26
|
+
timings?: {
|
|
27
|
+
start(label: string): void;
|
|
28
|
+
record(label: string): void;
|
|
29
|
+
};
|
|
30
|
+
}): Promise<Document>;
|
|
31
|
+
/**
|
|
32
|
+
* Parse the contents of the AsciiDoc source file into a Document.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} filename - The path to the AsciiDoc source file.
|
|
35
|
+
* @param {Object} [options={}] - Options to control processing.
|
|
36
|
+
* @returns {Promise<Document>} A Promise that resolves to the Document.
|
|
37
|
+
*/
|
|
38
|
+
export function loadFile(filename: string, options?: any): Promise<Document>;
|
|
39
|
+
import { Document } from './document.js';
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply the Logging mixin to a class prototype.
|
|
3
|
+
*
|
|
4
|
+
* Installs the following on proto:
|
|
5
|
+
* - `logger` getter — returns `LoggerManager.logger`
|
|
6
|
+
* - `getLogger()` — method alias for the logger getter
|
|
7
|
+
* - `messageWithContext(text, context)` — builds an auto-formatting message object
|
|
8
|
+
* - `createLogMessage(text, context)` — alias for messageWithContext (used in extensions)
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} proto - The prototype object (e.g. MyClass.prototype) to augment.
|
|
11
|
+
*/
|
|
12
|
+
export function applyLogging(proto: any): void;
|
|
13
|
+
export namespace Severity {
|
|
14
|
+
let DEBUG: number;
|
|
15
|
+
let INFO: number;
|
|
16
|
+
let WARN: number;
|
|
17
|
+
let ERROR: number;
|
|
18
|
+
let FATAL: number;
|
|
19
|
+
let UNKNOWN: number;
|
|
20
|
+
}
|
|
21
|
+
/** Standard logger that writes formatted messages to stderr or a custom pipe. */
|
|
22
|
+
export class Logger {
|
|
23
|
+
constructor(opts?: {});
|
|
24
|
+
progname: any;
|
|
25
|
+
level: any;
|
|
26
|
+
set formatter(f: any);
|
|
27
|
+
/** getter/setter so custom logger impls can access this.formatter */
|
|
28
|
+
get formatter(): any;
|
|
29
|
+
/**
|
|
30
|
+
* @returns {number|null} The highest severity level logged so far.
|
|
31
|
+
*/
|
|
32
|
+
get maxSeverity(): number | null;
|
|
33
|
+
getLevel(): any;
|
|
34
|
+
setLevel(n: any): void;
|
|
35
|
+
getFormatter(): any;
|
|
36
|
+
setFormatter(f: any): void;
|
|
37
|
+
getProgramName(): any;
|
|
38
|
+
setProgramName(n: any): void;
|
|
39
|
+
getMaxSeverity(): number;
|
|
40
|
+
/**
|
|
41
|
+
* @returns {boolean} Whether DEBUG-level messages will be logged.
|
|
42
|
+
*/
|
|
43
|
+
isDebugEnabled(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* @returns {boolean} Whether INFO-level messages will be logged.
|
|
46
|
+
*/
|
|
47
|
+
isInfoEnabled(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* @returns {boolean} Whether WARN-level messages will be logged.
|
|
50
|
+
*/
|
|
51
|
+
isWarnEnabled(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* @returns {boolean} Whether ERROR-level messages will be logged.
|
|
54
|
+
*/
|
|
55
|
+
isErrorEnabled(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* @returns {boolean} Whether FATAL-level messages will be logged.
|
|
58
|
+
*/
|
|
59
|
+
isFatalEnabled(): boolean;
|
|
60
|
+
isDebug(): boolean;
|
|
61
|
+
isInfo(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Log a message at the given severity level.
|
|
64
|
+
* @param {number|string} severity - Severity level (numeric constant or string name).
|
|
65
|
+
* @param {string|{inspect?(): string}|null} [message=null] - The message to log.
|
|
66
|
+
* @param {string|Function|null} [progname=null] - Program name or message supplier function.
|
|
67
|
+
* @returns {boolean}
|
|
68
|
+
*/
|
|
69
|
+
add(severity: number | string, message?: string | {
|
|
70
|
+
inspect?(): string;
|
|
71
|
+
} | null, progname?: string | Function | null): boolean;
|
|
72
|
+
/** Alias for {@link add} (Ruby Logger API). */
|
|
73
|
+
log(severity: any, message: any, progname: any): boolean;
|
|
74
|
+
debug(msg: any, progname: any): boolean;
|
|
75
|
+
info(msg: any, progname: any): boolean;
|
|
76
|
+
warn(msg: any, progname: any): boolean;
|
|
77
|
+
error(msg: any, progname: any): boolean;
|
|
78
|
+
fatal(msg: any, progname: any): boolean;
|
|
79
|
+
unknown(msg: any, progname: any): boolean;
|
|
80
|
+
}
|
|
81
|
+
export namespace Logger {
|
|
82
|
+
export { BasicFormatter };
|
|
83
|
+
export namespace AutoFormattingMessage {
|
|
84
|
+
/**
|
|
85
|
+
* Attach auto-formatting to any plain object carrying { text, source_location }.
|
|
86
|
+
* @param {{text: string, source_location?: string}} obj
|
|
87
|
+
* @returns {typeof obj} The same object with inspect() and toString() added.
|
|
88
|
+
*/
|
|
89
|
+
function attach(obj: {
|
|
90
|
+
text: string;
|
|
91
|
+
source_location?: string;
|
|
92
|
+
}): typeof obj;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** In-memory logger that stores all log messages for later inspection. */
|
|
96
|
+
export class MemoryLogger {
|
|
97
|
+
static create(): MemoryLogger;
|
|
98
|
+
level: number;
|
|
99
|
+
messages: any[];
|
|
100
|
+
getMessages(): any[];
|
|
101
|
+
getMaxSeverity(): number;
|
|
102
|
+
add(severity: any, message?: any, progname?: any): boolean;
|
|
103
|
+
debug(msg: any, pn: any): boolean;
|
|
104
|
+
info(msg: any, pn: any): boolean;
|
|
105
|
+
warn(msg: any, pn: any): boolean;
|
|
106
|
+
error(msg: any, pn: any): boolean;
|
|
107
|
+
fatal(msg: any, pn: any): boolean;
|
|
108
|
+
unknown(msg: any, pn: any): boolean;
|
|
109
|
+
log(severity: any, message: any, progname: any): boolean;
|
|
110
|
+
isDebug(): boolean;
|
|
111
|
+
isInfo(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Write a string at INFO level (trailing newline stripped).
|
|
114
|
+
* Allows MemoryLogger to be used with Timings.printReport().
|
|
115
|
+
* @param {string} s
|
|
116
|
+
* @returns {boolean}
|
|
117
|
+
*/
|
|
118
|
+
write(s: string): boolean;
|
|
119
|
+
clear(): void;
|
|
120
|
+
empty(): boolean;
|
|
121
|
+
}
|
|
122
|
+
/** Logger that discards all messages but still tracks the maximum severity. */
|
|
123
|
+
export class NullLogger {
|
|
124
|
+
static create(): NullLogger;
|
|
125
|
+
level: number;
|
|
126
|
+
_maxSeverity: number;
|
|
127
|
+
get maxSeverity(): number;
|
|
128
|
+
getMaxSeverity(): number;
|
|
129
|
+
add(severity: any): boolean;
|
|
130
|
+
log(severity: any): boolean;
|
|
131
|
+
debug(): boolean;
|
|
132
|
+
info(): boolean;
|
|
133
|
+
warn(): boolean;
|
|
134
|
+
error(): boolean;
|
|
135
|
+
fatal(): boolean;
|
|
136
|
+
unknown(): boolean;
|
|
137
|
+
}
|
|
138
|
+
export namespace LoggerManager {
|
|
139
|
+
let loggerClass: typeof Logger;
|
|
140
|
+
let logger: any;
|
|
141
|
+
function getLogger(): any;
|
|
142
|
+
function setLogger(newLogger: any): void;
|
|
143
|
+
/**
|
|
144
|
+
* Create a new formatter whose call() delegates to the provided impl.
|
|
145
|
+
* @param {string} _name
|
|
146
|
+
* @param {{call: Function}} impl
|
|
147
|
+
* @returns {{call: Function}}
|
|
148
|
+
*/
|
|
149
|
+
function newFormatter(_name: string, impl: {
|
|
150
|
+
call: Function;
|
|
151
|
+
}): {
|
|
152
|
+
call: Function;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Create a new Logger instance with custom behaviour supplied via impl.
|
|
156
|
+
* @param {string} _name
|
|
157
|
+
* @param {{add?: (severity: number, message: any, progname: any) => boolean, postConstruct?: (this: Logger) => void}} impl
|
|
158
|
+
* - `add(severity, message, progname)` — overrides the default add method; severity is always numeric.
|
|
159
|
+
* - `postConstruct()` — called once after the instance is created (`this` is the logger instance).
|
|
160
|
+
* @returns {Logger}
|
|
161
|
+
*/
|
|
162
|
+
function newLogger(_name: string, impl: {
|
|
163
|
+
add?: (severity: number, message: any, progname: any) => boolean;
|
|
164
|
+
postConstruct?: (this: Logger) => void;
|
|
165
|
+
}): Logger;
|
|
166
|
+
}
|
|
167
|
+
export namespace Logging {
|
|
168
|
+
const logger_1: any;
|
|
169
|
+
export { logger_1 as logger };
|
|
170
|
+
export function getLogger(): any;
|
|
171
|
+
export function messageWithContext(text: any, context?: {}): any;
|
|
172
|
+
export function createLogMessage(text: any, context?: {}): any;
|
|
173
|
+
}
|
|
174
|
+
declare class BasicFormatter {
|
|
175
|
+
/**
|
|
176
|
+
* Format a log entry as "progname: SEVERITY: message\n".
|
|
177
|
+
* @param {number|string} severity
|
|
178
|
+
* @param {null} _time
|
|
179
|
+
* @param {string} progname
|
|
180
|
+
* @param {string|{inspect?(): string}} msg
|
|
181
|
+
* @returns {string}
|
|
182
|
+
*/
|
|
183
|
+
call(severity: number | string, _time: null, progname: string, msg: string | {
|
|
184
|
+
inspect?(): string;
|
|
185
|
+
}): string;
|
|
186
|
+
}
|
|
187
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export class Parser {
|
|
2
|
+
/**
|
|
3
|
+
* Parse AsciiDoc source from reader into document.
|
|
4
|
+
* @param {Reader} reader
|
|
5
|
+
* @param {Document} document
|
|
6
|
+
* @param {{header_only?: boolean}} [options={}]
|
|
7
|
+
* @returns {Promise<Document>}
|
|
8
|
+
*/
|
|
9
|
+
static parse(reader: Reader, document: Document, options?: {
|
|
10
|
+
header_only?: boolean;
|
|
11
|
+
}): Promise<Document>;
|
|
12
|
+
/**
|
|
13
|
+
* Parse the document header.
|
|
14
|
+
* @param {Reader} reader
|
|
15
|
+
* @param {Document} document
|
|
16
|
+
* @param {boolean} [headerOnly=false]
|
|
17
|
+
* @returns {Promise<Object>} Block attributes after the header.
|
|
18
|
+
*/
|
|
19
|
+
static parseDocumentHeader(reader: Reader, document: Document, headerOnly?: boolean): Promise<any>;
|
|
20
|
+
/**
|
|
21
|
+
* Parse manpage header.
|
|
22
|
+
* @param {Reader} reader
|
|
23
|
+
* @param {Document} document
|
|
24
|
+
* @param {Object} blockAttributes
|
|
25
|
+
* @param {boolean} [headerOnly=false]
|
|
26
|
+
* @returns {Promise<void>}
|
|
27
|
+
*/
|
|
28
|
+
static parseManpageHeader(reader: Reader, document: Document, blockAttributes: any, headerOnly?: boolean): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Return the next section from the reader.
|
|
31
|
+
* @param {Reader} reader
|
|
32
|
+
* @param {Document|Section} parent
|
|
33
|
+
* @param {Object} [attributes={}]
|
|
34
|
+
* @returns {Promise<[Section|null, Object]>} Tuple of the new section (or null) and orphaned attributes.
|
|
35
|
+
*/
|
|
36
|
+
static nextSection(reader: Reader, parent: Document | Section, attributes?: any): Promise<[Section | null, any]>;
|
|
37
|
+
/**
|
|
38
|
+
* Parse and return the next Block at the Reader's current location.
|
|
39
|
+
* @param {Reader} reader
|
|
40
|
+
* @param {AbstractBlock} parent
|
|
41
|
+
* @param {Object} [attributes={}]
|
|
42
|
+
* @param {Object} [options={}]
|
|
43
|
+
* @returns {Promise<Block|null>}
|
|
44
|
+
*/
|
|
45
|
+
static nextBlock(reader: Reader, parent: AbstractBlock, attributes?: any, options?: any): Promise<Block | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Parse blocks from reader until exhausted.
|
|
48
|
+
* @param {Reader} reader
|
|
49
|
+
* @param {AbstractBlock} parent
|
|
50
|
+
* @param {Object|null} [attributes=null]
|
|
51
|
+
* @returns {Promise<void>}
|
|
52
|
+
*/
|
|
53
|
+
static parseBlocks(reader: Reader, parent: AbstractBlock, attributes?: any | null): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Check if line1 (and optionally line2) form a section title.
|
|
56
|
+
* @param {string} line1
|
|
57
|
+
* @param {string|null} [line2=null]
|
|
58
|
+
* @returns {number|null} The section level, or null.
|
|
59
|
+
*/
|
|
60
|
+
static isSectionTitle(line1: string, line2?: string | null): number | null;
|
|
61
|
+
/**
|
|
62
|
+
* Parse section title from reader.
|
|
63
|
+
* @param {Reader} reader
|
|
64
|
+
* @param {Document} document
|
|
65
|
+
* @param {string|null} [sectId=null]
|
|
66
|
+
* @returns {Promise<[string|null, string|null, string, number, boolean]>} Tuple of [id, reftext, title, level, atx].
|
|
67
|
+
*/
|
|
68
|
+
static parseSectionTitle(reader: Reader, document: Document, sectId?: string | null): Promise<[string | null, string | null, string, number, boolean]>;
|
|
69
|
+
/**
|
|
70
|
+
* Parse header metadata (author line and revision line).
|
|
71
|
+
* @param {Reader} reader
|
|
72
|
+
* @param {Document|null} [document=null]
|
|
73
|
+
* @param {boolean} [retrieve=true]
|
|
74
|
+
* @returns {Promise<Object|null>}
|
|
75
|
+
*/
|
|
76
|
+
static parseHeaderMetadata(reader: Reader, document?: Document | null, retrieve?: boolean): Promise<any | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Store the attribute in the document.
|
|
79
|
+
* @param {string} name
|
|
80
|
+
* @param {string} value
|
|
81
|
+
* @param {Document|null} [doc=null]
|
|
82
|
+
* @param {Object|null} [attrs=null]
|
|
83
|
+
* @param {Object} [opts={}]
|
|
84
|
+
* @returns {[string, string|null]} Tuple of the resolved name and value.
|
|
85
|
+
*/
|
|
86
|
+
static storeAttribute(name: string, value: string, doc?: Document | null, attrs?: any | null, opts?: any): [string, string | null];
|
|
87
|
+
/**
|
|
88
|
+
* Check if line is the start of a delimited block.
|
|
89
|
+
* @param {string} line
|
|
90
|
+
* @param {boolean} [returnMatchData=false]
|
|
91
|
+
* @returns {{context: string, masq: string[], tip: string, terminator: string}|true|null}
|
|
92
|
+
* BlockMatchData object if returnMatchData is true, true/null otherwise.
|
|
93
|
+
*/
|
|
94
|
+
static isDelimitedBlock(line: string, returnMatchData?: boolean): {
|
|
95
|
+
context: string;
|
|
96
|
+
masq: string[];
|
|
97
|
+
tip: string;
|
|
98
|
+
terminator: string;
|
|
99
|
+
} | true | null;
|
|
100
|
+
/**
|
|
101
|
+
* Parse the first positional attribute for style, role, id, and options.
|
|
102
|
+
* @param {Object} attributes
|
|
103
|
+
* @param {Reader|null} [reader=null]
|
|
104
|
+
* @returns {string|null} The resolved style value.
|
|
105
|
+
*/
|
|
106
|
+
static parseStyleAttribute(attributes: any, reader?: Reader | null): string | null;
|
|
107
|
+
static _yieldBufferedAttribute(attrs: any, name: any, value: any, reader: any): void;
|
|
108
|
+
}
|
|
109
|
+
import { Reader } from './reader.js';
|
|
110
|
+
import { Section } from './section.js';
|
|
111
|
+
import { Block } from './block.js';
|
|
112
|
+
import { List } from './list.js';
|
|
113
|
+
import { ListItem } from './list.js';
|
|
114
|
+
import { Table } from './table.js';
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** Handles all operations for resolving, cleaning and joining paths. */
|
|
2
|
+
export class PathResolver {
|
|
3
|
+
/**
|
|
4
|
+
* Construct a new PathResolver.
|
|
5
|
+
* @param {string|null} fileSeparator - The file separator (default: '/' or '\\' on Windows).
|
|
6
|
+
* @param {string|null} workingDir - The working directory (default: process.cwd()).
|
|
7
|
+
*/
|
|
8
|
+
constructor(fileSeparator?: string | null, workingDir?: string | null);
|
|
9
|
+
fileSeparator: string;
|
|
10
|
+
workingDir: any;
|
|
11
|
+
_partitionPathSys: {};
|
|
12
|
+
_partitionPathWeb: {};
|
|
13
|
+
/**
|
|
14
|
+
* Check whether the specified path is an absolute path.
|
|
15
|
+
* @param {string} path
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/
|
|
18
|
+
absolutePath(path: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if the specified path is an absolute root path.
|
|
21
|
+
* @param {string} path
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
root(path: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Determine if the path is a UNC (root) path.
|
|
27
|
+
* @param {string} path
|
|
28
|
+
* @returns {boolean}
|
|
29
|
+
*/
|
|
30
|
+
unc(path: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Determine if the path is an absolute (root) web path.
|
|
33
|
+
* @param {string} path
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
webRoot(path: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Determine whether path descends from base.
|
|
39
|
+
* @param {string} path
|
|
40
|
+
* @param {string} base
|
|
41
|
+
* @returns {number|false} Offset if path descends from base, false otherwise.
|
|
42
|
+
*/
|
|
43
|
+
descendsFrom(path: string, base: string): number | false;
|
|
44
|
+
/**
|
|
45
|
+
* Calculate the relative path to this absolute path from the specified base directory.
|
|
46
|
+
* @param {string} path
|
|
47
|
+
* @param {string} base
|
|
48
|
+
* @returns {string} Relative path, or the original path if it cannot be made relative.
|
|
49
|
+
*/
|
|
50
|
+
relativePath(path: string, base: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Normalize path by converting backslashes to forward slashes.
|
|
53
|
+
* @param {string} path
|
|
54
|
+
* @returns {string} The posixified path.
|
|
55
|
+
*/
|
|
56
|
+
posixify(path: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} path
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
posixfy(path: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Expand the path by resolving parent references (..) and removing self references (.).
|
|
64
|
+
* @param {string} path
|
|
65
|
+
* @returns {string} The expanded path.
|
|
66
|
+
*/
|
|
67
|
+
expandPath(path: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Partition the path into segments and a root prefix.
|
|
70
|
+
* @param {string} path - The path to partition.
|
|
71
|
+
* @param {boolean} [web=false] - Treat as web path.
|
|
72
|
+
* @returns {[string[], string|null]} A 2-item array [segments, root] where root may be null.
|
|
73
|
+
*/
|
|
74
|
+
partitionPath(path: string, web?: boolean): [string[], string | null];
|
|
75
|
+
/**
|
|
76
|
+
* Join segments with posix separator, prepending root if provided.
|
|
77
|
+
* @param {string[]} segments
|
|
78
|
+
* @param {string|null} [root=null]
|
|
79
|
+
* @returns {string} The joined path.
|
|
80
|
+
*/
|
|
81
|
+
joinPath(segments: string[], root?: string | null): string;
|
|
82
|
+
/**
|
|
83
|
+
* Securely resolve a system path.
|
|
84
|
+
* @param {string} target - The target path.
|
|
85
|
+
* @param {string|null} [start=null] - The start path.
|
|
86
|
+
* @param {string|null} [jail=null] - The jail path.
|
|
87
|
+
* @param {Object} [opts={}] - Options.
|
|
88
|
+
* @param {boolean} [opts.recover=true] - Recover from jail escapes instead of throwing.
|
|
89
|
+
* @param {string} [opts.targetName='path'] - Name used in error messages.
|
|
90
|
+
* @returns {string} An absolute posix path.
|
|
91
|
+
*/
|
|
92
|
+
systemPath(target: string, start?: string | null, jail?: string | null, opts?: {
|
|
93
|
+
recover?: boolean;
|
|
94
|
+
targetName?: string;
|
|
95
|
+
}): string;
|
|
96
|
+
/**
|
|
97
|
+
* Resolve a web path from the target and start paths.
|
|
98
|
+
* @param {string} target - The target path.
|
|
99
|
+
* @param {string|null} [start=null] - The start (parent) path.
|
|
100
|
+
* @returns {string} Path with parent references resolved and self references removed.
|
|
101
|
+
*/
|
|
102
|
+
webPath(target: string, start?: string | null): string;
|
|
103
|
+
}
|