@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.
Files changed (92) hide show
  1. package/README.md +42 -10
  2. package/build/browser/index.js +24156 -0
  3. package/build/node/index.cjs +24737 -0
  4. package/{dist/css/asciidoctor.css → data/asciidoctor-default.css} +54 -53
  5. package/package.json +55 -97
  6. package/src/abstract_block.js +857 -0
  7. package/src/abstract_node.js +954 -0
  8. package/src/attribute_entry.js +12 -0
  9. package/src/attribute_list.js +380 -0
  10. package/src/block.js +168 -0
  11. package/src/browser/asset.js +22 -0
  12. package/src/browser/reader.js +138 -0
  13. package/src/browser.js +121 -0
  14. package/src/callouts.js +85 -0
  15. package/src/compliance.js +54 -0
  16. package/src/constants.js +665 -0
  17. package/src/convert.js +370 -0
  18. package/src/converter/composite.js +83 -0
  19. package/src/converter/docbook5.js +1031 -0
  20. package/src/converter/html5.js +1893 -0
  21. package/src/converter/manpage.js +935 -0
  22. package/src/converter/template.js +459 -0
  23. package/src/converter.js +478 -0
  24. package/src/data/stylesheet-data.js +2 -0
  25. package/src/document.js +2134 -0
  26. package/src/extensions.js +1952 -0
  27. package/src/footnote.js +28 -0
  28. package/src/helpers.js +355 -0
  29. package/src/index.js +138 -0
  30. package/src/inline.js +158 -0
  31. package/src/list.js +240 -0
  32. package/src/load.js +276 -0
  33. package/src/logging.js +526 -0
  34. package/src/parser.js +3661 -0
  35. package/src/path_resolver.js +472 -0
  36. package/src/reader.js +1755 -0
  37. package/src/rx.js +829 -0
  38. package/src/section.js +354 -0
  39. package/src/stylesheets.js +30 -0
  40. package/src/substitutors.js +2241 -0
  41. package/src/syntaxHighlighter/highlightjs.js +90 -0
  42. package/src/syntaxHighlighter/html_pipeline.js +33 -0
  43. package/src/syntax_highlighter.js +304 -0
  44. package/src/table.js +952 -0
  45. package/src/timings.js +78 -0
  46. package/types/abstract_block.d.ts +346 -0
  47. package/types/abstract_node.d.ts +471 -0
  48. package/types/attribute_entry.d.ts +7 -0
  49. package/types/attribute_list.d.ts +52 -0
  50. package/types/block.d.ts +55 -0
  51. package/types/browser/asset.d.ts +7 -0
  52. package/types/browser/reader.d.ts +29 -0
  53. package/types/callouts.d.ts +36 -0
  54. package/types/compliance.d.ts +23 -0
  55. package/types/constants.d.ts +268 -0
  56. package/types/convert.d.ts +34 -0
  57. package/types/converter/composite.d.ts +20 -0
  58. package/types/converter/docbook5.d.ts +41 -0
  59. package/types/converter/html5.d.ts +51 -0
  60. package/types/converter/manpage.d.ts +59 -0
  61. package/types/converter/template.d.ts +83 -0
  62. package/types/converter.d.ts +150 -0
  63. package/types/data/stylesheet-data.d.ts +2 -0
  64. package/types/document.d.ts +495 -0
  65. package/types/extensions.d.ts +876 -0
  66. package/types/footnote.d.ts +18 -0
  67. package/types/helpers.d.ts +146 -0
  68. package/types/index.d.cts +75 -0
  69. package/types/index.d.ts +73 -3731
  70. package/types/inline.d.ts +69 -0
  71. package/types/list.d.ts +114 -0
  72. package/types/load.d.ts +39 -0
  73. package/types/logging.d.ts +187 -0
  74. package/types/parser.d.ts +114 -0
  75. package/types/path_resolver.d.ts +103 -0
  76. package/types/reader.d.ts +184 -0
  77. package/types/rx.d.ts +513 -0
  78. package/types/section.d.ts +122 -0
  79. package/types/stylesheets.d.ts +10 -0
  80. package/types/substitutors.d.ts +208 -0
  81. package/types/syntaxHighlighter/highlightjs.d.ts +33 -0
  82. package/types/syntaxHighlighter/html_pipeline.d.ts +16 -0
  83. package/types/syntax_highlighter.d.ts +167 -0
  84. package/types/table.d.ts +231 -0
  85. package/types/timings.d.ts +25 -0
  86. package/types/tsconfig.json +9 -0
  87. package/LICENSE +0 -21
  88. package/dist/browser/asciidoctor.js +0 -47654
  89. package/dist/browser/asciidoctor.min.js +0 -1452
  90. package/dist/graalvm/asciidoctor.js +0 -47402
  91. package/dist/node/asciidoctor.cjs +0 -21567
  92. package/dist/node/asciidoctor.js +0 -23037
package/types/index.d.ts CHANGED
@@ -1,3732 +1,74 @@
1
- /// <reference types="node" />
2
- // TypeScript Version: 3.7
3
- type Author = Document.Author;
4
- type Title = Document.Title;
5
- type TitleOptions = Document.Title.Options;
6
- type Registry = Extensions.Registry;
7
- type Cursor = Reader.Cursor;
8
-
9
- declare class OpalKlass<T> {
10
- $new(...params: any[]): T;
11
- }
12
-
13
- interface Runtime {
14
- ioModule: string | 'node';
15
- platform: string | 'node';
16
- engine: string | 'v8';
17
- framework: string;
18
- }
19
-
20
- export class Reader implements Logging {
21
- /**
22
- * Push source onto the front of the reader and switch the context based on the file, document-relative path and line information given.
23
- *
24
- * This method is typically used in an IncludeProcessor to add source read from the target specified.
25
- *
26
- * @param data - data
27
- * @param file - file
28
- * @param path - path
29
- * @param lineno - line number
30
- * @param attributes - a JSON of attributes
31
- * @returns this {Reader} object.
32
- */
33
- pushInclude(data: string | string[], file?: string, path?: string, lineno?: number, attributes?: object): Reader;
34
-
35
- /**
36
- * Get the current location of the reader's cursor, which encapsulates the file, dir, path, and lineno of the file being read.
37
- */
38
- getCursor(): Cursor;
39
-
40
- /**
41
- * Get the remaining unprocessed lines, without consuming them, as an {Array} of {string}.
42
- *
43
- * Lines will not be consumed from the Reader (ie. you will be able to read these lines again).
44
- *
45
- * @returns the remaining unprocessed lines as an Array of String.
46
- */
47
- getLines(): string[];
48
-
49
- /**
50
- * Get the remaining unprocessed lines, without consuming them, as a String.
51
- *
52
- * Lines will not be consumed from the Reader (ie. you will be able to read these lines again).
53
- *
54
- * @returns the remaining unprocessed lines as a String (joined by linefeed characters).
55
- */
56
- getString(): string;
57
-
58
- /**
59
- * Check whether there are any lines left to read.
60
- * If a previous call to this method resulted in a value of false, immediately returned the cached value.
61
- * Otherwise, delegate to peekLine to determine if there is a next line available.
62
- *
63
- * @returns true if there are more lines, false if there are not.
64
- */
65
- hasMoreLines(): boolean;
66
-
67
- /**
68
- * Check whether this reader is empty (contains no lines).
69
- *
70
- * @returns true if there are no more lines to peek, otherwise false.
71
- */
72
- isEmpty(): boolean;
73
-
74
- /**
75
- * Peek at the next line.
76
- * Processes the line if not already marked as processed, but does not consume it (ie. you will be able to read this line again).
77
- *
78
- * This method will probe the reader for more lines.
79
- * If there is a next line that has not previously been visited, the line is passed to the Reader#processLine method to be initialized.
80
- * This call gives sub-classes the opportunity to do preprocessing.
81
- * If the return value of the Reader#processLine is undefined, the data is assumed to be changed and Reader#peekLine is invoked again to perform further processing.
82
- *
83
- * If hasMoreLines is called immediately before peekLine, the direct flag is implicitly true (since the line is flagged as visited).
84
- *
85
- * @param direct - A {boolean} flag to bypasses the check for more lines and immediately returns the first element of the internal lines {Array}. (default: false)
86
- * @returns the next line as a {string} if there are lines remaining.
87
- */
88
- peekLine(direct: boolean): string;
89
-
90
- /**
91
- * Consume, preprocess, and return the next line.
92
- *
93
- * Line will be consumed from the Reader (ie. you won't be able to read this line again).
94
- *
95
- * @returns the next line as a {string} if data is present.
96
- */
97
- readLine(): string;
98
-
99
- /**
100
- * Consume, preprocess, and return the remaining lines.
101
- *
102
- * This method calls Reader#readLine repeatedly until all lines are consumed and returns the lines as an {Array} of {string}.
103
- * This method differs from Reader#getLines in that it processes each line in turn, hence triggering any preprocessors implemented in sub-classes.
104
- *
105
- * Lines will be consumed from the Reader (ie. you won't be able to read these lines again).
106
- *
107
- * @returns the lines read as an {Array} of {string}.
108
- */
109
- readLines(): string[];
110
-
111
- /**
112
- * Consume, preprocess, and return the remaining lines joined as a {string}.
113
- *
114
- * Delegates to Reader#readLines, then joins the result.
115
- *
116
- * Lines will be consumed from the Reader (ie. you won't be able to read these lines again).
117
- *
118
- * @returns the lines read joined as a {string}
119
- */
120
- read(): string;
121
-
122
- /**
123
- * Advance to the next line by discarding the line at the front of the stack.
124
- * @returns a Boolean indicating whether there was a line to discard.
125
- */
126
- advance(): boolean;
127
-
128
- getLogger(): Logger;
129
-
130
- createLogMessage(text: string, context: any): LoggerMessage;
131
- }
132
-
133
- export namespace Reader {
134
- /**
135
- *
136
- */
137
- class Cursor {
138
- /**
139
- * @returns the file associated to the cursor
140
- */
141
- getFile(): string | undefined;
142
-
143
- /**
144
- * @returns the directory associated to the cursor
145
- */
146
- getDirectory(): string | undefined;
147
-
148
- /**
149
- * @returns the path associated to the cursor (or '<stdin>')
150
- */
151
- getPath(): string | undefined;
152
-
153
- /**
154
- * Get the line number of the cursor.
155
- * @returns the line number of the cursor
156
- */
157
- getLineNumber(): number | undefined;
158
- }
159
- }
160
-
161
- export namespace SafeMode {
162
- /**
163
- * A safe mode level that disables any of the security features enforced by
164
- */
165
- const UNSAFE: number;
166
-
167
- /**
168
- * A safe mode level that closely parallels safe mode in AsciiDoc.
169
- * This value prevents access to files which reside outside of the parent directory of the source file and disables any macro other than the include::[] directive.
170
- */
171
- const SAFE: number;
172
-
173
- /**
174
- * A safe mode level that disallows the document from setting attributes that would affect the conversion of the document,
175
- * in addition to all the security features of {SafeMode.SAFE}.
176
- * For instance, this level forbids changing the backend or source-highlighter using an attribute defined in the source document header.
177
- * This is the most fundamental level of security for server deployments (hence the name).
178
- */
179
- const SERVER: number;
180
-
181
- /**
182
- * A safe mode level that disallows the document from attempting to read files from the file system and including the contents of them into the document,
183
- * in additional to all the security features of SafeMode.SERVER}.
184
- * For instance, this level disallows use of the include::[] directive and the embedding of binary content (data uri), stylesheets and JavaScripts referenced by the document.
185
- * (Asciidoctor and trusted extensions may still be allowed to embed trusted content into the document).
186
- * Since Asciidoctor is aiming for wide adoption, this level is the default and is recommended for server deployments.
187
- */
188
- const SECURE: number;
189
-
190
- /**
191
- * @param name - the name of the security level
192
- * @returns the integer value of the corresponding security level.
193
- */
194
- function getValueForName(name: string): number;
195
-
196
- /**
197
- * @param value - the integer value of the security level
198
- * @returns the name of the corresponding security level.
199
- */
200
- function getNameForValue(value: number): string | undefined;
201
-
202
- /**
203
- * @returns the String {Array} of security levels.
204
- */
205
- function getNames(): string[];
206
- }
207
-
208
- interface Callout {
209
- [key: string]: any;
210
-
211
- id?: string;
212
- ordinal?: number;
213
- }
214
-
215
1
  /**
216
- * Maintains a catalog of callouts and their associations.
217
- */
218
- export class Callouts {
219
- /**
220
- * Create a new Callouts.
221
- * @returns a new Callouts
222
- */
223
- static create(): Callouts;
224
-
225
- /**
226
- * Register a new callout for the given list item ordinal.
227
- * Generates a unique id for this callout based on the index of the next callout list in the document and the index of this callout since the end of the last callout list.
228
- *
229
- * @param ordinal - the Integer ordinal (1-based) of the list item to which this callout is to be associated
230
- * @returns The unique String id of this callout
231
- * @example
232
- * callouts = asciidoctor.Callouts.create()
233
- * callouts.register(1)
234
- * // => "CO1-1"
235
- * callouts.nextList()
236
- * callouts.register(2)
237
- * // => "CO2-1"
238
- */
239
- register(ordinal: number): string;
240
-
241
- /**
242
- * Get the next callout index in the document.
243
- *
244
- * Reads the next callout index in the document and advances the pointer.
245
- * This method is used during conversion to retrieve the unique id of the callout that was generated during parsing.
246
- *
247
- * @returns The unique String id of the next callout in the document
248
- */
249
- readNextId(): string;
250
-
251
- /**
252
- *
253
- */
254
- getLists(): Callout[][];
255
-
256
- /**
257
- *
258
- */
259
- getListIndex(): number;
260
-
261
- /**
262
- * et a space-separated list of callout ids for the specified list item.
263
- * @param ordinal - the Integer ordinal (1-based) of the list item for which to retrieve the callouts
264
- * @returns a space-separated String of callout ids associated with the specified list item
265
- */
266
- getCalloutIds(ordinal: number): string;
267
-
268
- /**
269
- * The current list for which callouts are being collected.
270
- * @returns The Array of callouts at the position of the list index pointer
271
- */
272
- getCurrentList(): any[];
273
-
274
- /**
275
- * Advance to the next callout list in the document.
276
- */
277
- nextList(): void;
278
-
279
- /**
280
- * Rewind the list index pointer, intended to be used when switching from the parsing to conversion phase.
281
- */
282
- rewind(): void;
283
- }
284
-
285
- /**
286
- * Logger
287
- */
288
- interface LoggerFormatterFunction {
289
- postConstruct?: (this: LoggerFormatter) => any;
290
- call?: (this: LoggerFormatter, severity: string, time: Date, programName: string, message: string | RubyLoggerMessage) => string;
291
- }
292
-
293
- interface LoggerFunction {
294
- postConstruct?: (this: Logger) => any;
295
- add?: (this: Logger, severity: string, message: string | RubyLoggerMessage | undefined, programName: string) => void;
296
- }
297
-
298
- export namespace LoggerManager {
299
- function getLogger(): Logger;
300
-
301
- function setLogger(logger: Logger): void;
302
-
303
- function newLogger(name: string, functions: LoggerFunction): Logger;
304
-
305
- function newFormatter(name: string, functions: LoggerFormatterFunction): LoggerFormatter;
306
- }
307
-
308
- interface Writer {
309
- write(message: string | LoggerMessage): void;
310
- }
311
-
312
- interface BasicLogger {
313
- log(message: string | LoggerMessage): void;
314
- }
315
-
316
- declare class RubyLogger {
317
- $add(severity: string | number, message: string | LoggerMessage, programName?: string): any;
318
-
319
- add(severity: string | number, message: string | LoggerMessage, programName?: string): any;
320
-
321
- log(severity: string | number, message: string | LoggerMessage, programName?: string): any;
322
-
323
- debug(message: string): any;
324
-
325
- info(message: string): any;
326
-
327
- warn(message: string): any;
328
-
329
- error(message: string): any;
330
-
331
- fatal(message: string): any;
332
-
333
- isDebugEnabled(): boolean;
334
-
335
- isInfoEnabled(): boolean;
336
-
337
- isWarnEnabled(): boolean;
338
-
339
- isErrorEnabled(): boolean;
340
-
341
- isFatalEnabled(): boolean;
342
- }
343
-
344
- export class Logger extends RubyLogger {
345
- [key: string]: any;
346
-
347
- formatter: LoggerFormatter;
348
-
349
- getMaxSeverity(): undefined | number;
350
-
351
- getFormatter(): LoggerFormatter;
352
-
353
- setFormatter(formatter: LoggerFormatter): any;
354
-
355
- getLevel(): number;
356
-
357
- setLevel(level: number): any;
358
-
359
- getProgramName(): string;
360
-
361
- setProgramName(programName: string): any;
362
- }
363
-
364
- export class MemoryLogger extends Logger {
365
- /**
366
- * Create a new MemoryLogger.
367
- * @returns a new MemoryLogger
368
- */
369
- static create(): MemoryLogger;
370
-
371
- getMessages(): LoggerMessage[];
372
- }
373
-
374
- export class NullLogger extends Logger {
375
- /**
376
- * Create a new NullLogger.
377
- * @returns a new NullLogger
378
- */
379
- static create(): NullLogger;
380
-
381
- getMaxSeverity(): undefined | number;
382
- }
383
-
384
- export class LoggerFormatter {
385
- call(severity: string, time: Date, programName: string, message: string): string;
386
- }
387
-
388
- interface Logging {
389
- getLogger(): Logger;
390
-
391
- createLogMessage(text: string, context: any): LoggerMessage;
392
- }
393
-
394
- export namespace LoggerSeverity {
395
- function get(severity: string): number;
396
- }
397
-
398
- interface RubyLoggerMessage {
399
- message: string;
400
- source_location: SourceLocation;
401
- text: string;
402
- }
403
-
404
- export class LoggerMessage implements RubyLoggerMessage {
405
- message: string;
406
- source_location: SourceLocation;
407
- text: string;
408
-
409
- getText(): string;
410
-
411
- getSeverity(): string;
412
-
413
- getSourceLocation(): SourceLocation;
414
- }
415
-
416
- interface SourceLocation {
417
- getLineNumber(): number;
418
-
419
- getFile(): undefined | string;
420
-
421
- getDirectory(): string;
422
-
423
- getPath(): string;
424
- }
425
-
426
- export class Timings {
427
- /**
428
- * Create a new Timings.
429
- * @returns a Timings
430
- */
431
- static create(): Timings;
432
-
433
- /**
434
- * Print a report to the specified output.
435
- * The report will include:
436
- * - the time to read and parse source
437
- * - the time to convert document
438
- * - the total time (read, parse and convert)
439
- * @param to - an optional output (by default stdout)
440
- * @param subject - an optional subject (usually the file name)
441
- */
442
- printReport(to?: Writer | BasicLogger | RubyLogger, subject?: string): void;
443
- }
444
-
445
- export namespace Document {
446
- /**
447
- * The Author class represents information about an author extracted from document attributes.
448
- */
449
- class Author {
450
- /**
451
- * @returns the author's full name
452
- */
453
- getName(): string | undefined;
454
-
455
- /**
456
- * @returns the author's first name
457
- */
458
- getFirstName(): string | undefined;
459
-
460
- /**
461
- * @returns the author's middle name (or undefined if the author has no middle name)
462
- */
463
- getMiddleName(): string | undefined;
464
-
465
- /**
466
- * @returns the author's last name
467
- */
468
- getLastName(): string | undefined;
469
-
470
- /**
471
- * @returns the author's initials (by default based on the author's name)
472
- */
473
- getInitials(): string | undefined;
474
-
475
- /**
476
- * @returns the author's email
477
- */
478
- getEmail(): string | undefined;
479
- }
480
-
481
- namespace Title {
482
- interface Options {
483
- partition?: boolean;
484
- sanitize?: boolean;
485
- use_fallback?: boolean;
486
- }
487
- }
488
-
489
- /**
490
- *
491
- */
492
- class Footnote {
493
- /**
494
- * @returns the footnote's index
495
- */
496
- getIndex(): number | undefined;
497
-
498
- /**
499
- * @returns the footnote's id
500
- */
501
- getId(): number | undefined;
502
-
503
- /**
504
- * @returns the footnote's text
505
- */
506
- getText(): string | undefined;
507
- }
508
-
509
- interface AttributeEntry {
510
- name: string;
511
- value: string;
512
- negate: boolean;
513
- }
514
-
515
- /**
516
- *
517
- */
518
- class ImageReference {
519
- /**
520
- * @returns the image's target
521
- */
522
- getTarget(): string;
523
-
524
- /**
525
- * @returns the image's directory (imagesdir attribute)
526
- */
527
- getImagesDirectory(): string | undefined;
528
- }
529
-
530
- /**
531
- * The Title class represents a partitioned title (i.e., title & subtitle).
532
- */
533
- class Title {
534
- getMain(): string;
535
-
536
- getCombined(): string;
537
-
538
- getSubtitle(): string;
539
-
540
- isSanitized(): boolean;
541
-
542
- hasSubtitle(): boolean;
543
- }
544
-
545
- class RevisionInfo {
546
- /**
547
- * Get the document revision date from document header (document attribute <code>revdate</code>).
548
- */
549
- getDate(): string;
550
-
551
- /**
552
- * Get the document revision number from document header (document attribute <code>revnumber</code>).
553
- */
554
- getNumber(): string;
555
-
556
- /**
557
- * Get the document revision remark from document header (document attribute <code>revremark</code>).
558
- * A short summary of changes in this document revision.
559
- */
560
- getRemark(): string;
561
-
562
- /**
563
- * @returns true if the revision info is empty (ie. not defined), otherwise false
564
- */
565
- isEmpty(): boolean;
566
- }
567
- }
568
-
569
- export namespace Image {
570
- interface Attributes {
571
- [key: string]: any;
572
-
573
- target: string;
574
- alt?: string;
575
- title?: string;
576
- caption?: string;
577
- }
578
- }
579
-
580
- interface Attributes {
581
- [key: string]: any;
582
- }
583
-
584
- export namespace Inline {
585
- interface Options {
586
- [key: string]: any;
587
-
588
- id?: string;
589
- type?: string;
590
- target?: string;
591
- attributes?: Attributes;
592
- }
593
- }
594
-
595
- export namespace Block {
596
- interface Options {
597
- [key: string]: any;
598
-
599
- content_model?: string;
600
- subs?: string | string[];
601
- }
602
-
603
- interface Attributes {
604
- attribute_entries?: Document.AttributeEntry[];
605
- }
606
- }
607
-
608
- interface Selector {
609
- [key: string]: any;
610
- }
611
-
612
- interface ParseAttributesOptions {
613
- [key: string]: any;
614
-
615
- positional_attributes?: string | string[];
616
- sub_attributes?: boolean;
617
- }
618
-
619
- interface Options {
620
- [key: string]: any;
621
- }
622
-
623
- interface ProcessorOptions {
624
- [key: string]: any;
625
-
626
- /**
627
- * Sets additional document attributes, which override equivalently-named attributes defined in the document unless the value ends with @.
628
- * Any number of built-in or user-defined attributes in one of the following formats:
629
- * - JSON: {'name': 'value'}
630
- * - Array:['name=value']
631
- * - String: 'name=value'
632
- */
633
- attributes?: Attributes | string[] | string;
634
- /**
635
- * Selects the converter to use (as registered with this keyword).
636
- */
637
- backend?: string;
638
- /**
639
- * Sets the base (aka working) directory containing the document and resources.
640
- */
641
- base_dir?: string;
642
- /**
643
- * If true, tells the parser to capture images and links in the reference table.
644
- * (Normally only IDs, footnotes and indexterms are included).
645
- * The reference table is available via the references property on the document AST object.
646
- * (Experimental).
647
- */
648
- catalog_assets?: boolean;
649
- /**
650
- * Sets the document type.
651
- */
652
- doctype?: string;
653
- /**
654
- * Overrides the extensions registry instance.
655
- * Instead of providing a JavaScript function containing extensions to register,
656
- * this option lets you replace the extension registry itself,
657
- * giving you complete control over how extensions are registered for this processor.
658
- */
659
- extension_registry?: Registry;
660
- /**
661
- * @deprecated Please use {@link ProcessorOptions#standalone}
662
- */
663
- header_footer?: boolean;
664
- /**
665
- * If true, add the document header and footer (i.e., framing) around the body content in the output.
666
- */
667
- standalone?: boolean;
668
- /**
669
- * If true, the processor will create the necessary output directories if they don’t yet exist.
670
- */
671
- mkdirs?: boolean;
672
- /**
673
- * If true, the source is parsed eagerly (i.e., as soon as the source is passed to the load or loadFile API).
674
- * If false, parsing is deferred until the parse method is explicitly invoked.
675
- */
676
- parse?: boolean;
677
- /**
678
- * Sets the safe mode.
679
- */
680
- safe?: string | number;
681
- /**
682
- * Keeps track of the file and line number for each parsed block.
683
- * (Useful for tooling applications where the association between the converted output and the source file is important).
684
- */
685
- sourcemap?: boolean;
686
- /**
687
- * An array of directories containing templates to be used instead of the default built-in templates.
688
- */
689
- template_dirs?: string[];
690
- /**
691
- * Capture time taken to read, parse, and convert document. Internal use only.
692
- */
693
- timings?: Timings;
694
- /**
695
- * Destination directory for output file(s), relative to base_dir.
696
- */
697
- to_dir?: string;
698
- /**
699
- * The name of the output file to write, or true to use the default output file (docname + outfilesuffix).
700
- */
701
- to_file?: boolean | string;
702
- }
703
-
704
- /**
705
- * @description
706
- * Extensions provide a way to participate in the parsing and converting
707
- * phases of the AsciiDoc processor or extend the AsciiDoc syntax.
708
- *
709
- * The various extensions participate in AsciiDoc processing as follows:
710
- *
711
- * 1. After the source lines are normalized, {{@link Extensions/Preprocessor}}s modify or replace
712
- * the source lines before parsing begins. {{@link Extensions/IncludeProcessor}}s are used to
713
- * process include directives for targets which they claim to handle.
714
- * 2. The Parser parses the block-level content into an abstract syntax tree.
715
- * Custom blocks and block macros are processed by associated {{@link Extensions/BlockProcessor}}s
716
- * and {{@link Extensions/BlockMacroProcessor}}s, respectively.
717
- * 3. {{@link Extensions/TreeProcessor}}s are run on the abstract syntax tree.
718
- * 4. Conversion of the document begins, at which point inline markup is processed
719
- * and converted. Custom inline macros are processed by associated {InlineMacroProcessor}s.
720
- * 5. {{@link Extensions/Postprocessor}}s modify or replace the converted document.
721
- * 6. The output is written to the output stream.
722
- *
723
- * Extensions may be registered globally using the {Extensions.register} method
724
- * or added to a custom {Registry} instance and passed as an option to a single
725
- * Asciidoctor processor.
726
- *
727
- * @example
728
- * asciidoctor.Extensions.register(function () {
729
- * this.block(function () {
730
- * var self = this;
731
- * self.named('shout');
732
- * self.onContext('paragraph');
733
- * self.process(function (parent, reader) {
734
- * var lines = reader.getLines().map(function (l) { return l.toUpperCase(); });
735
- * return this.createBlock(parent, 'paragraph', lines);
736
- * });
737
- * });
738
- * });
739
- */
740
- export namespace Extensions {
741
- /**
742
- * Tree processor functions
743
- */
744
- interface TreeProcessorFunctions {
745
- postConstruct?: (this: TreeProcessorInstance) => any;
746
- initialize?: (this: TreeProcessorInstance, name: string, config: any) => void;
747
- process: (this: TreeProcessorInstance, parent: Document) => any;
748
- }
749
-
750
- interface TreeProcessorInstance extends TreeProcessor {
751
- [key: string]: any;
752
-
753
- super: (...params: any[]) => void;
754
- }
755
-
756
- /**
757
- * Include processor functions
758
- */
759
- interface IncludeProcessorFunctions {
760
- postConstruct?: (this: IncludeProcessorInstance) => any;
761
- initialize?: (this: IncludeProcessorInstance, name: string, config: any) => void;
762
- process: (this: IncludeProcessorInstance, document: Document, reader: Reader, target: string, attributes: any) => void;
763
- }
764
-
765
- interface IncludeProcessorInstance extends IncludeProcessor {
766
- [key: string]: any;
767
-
768
- super: (...params: any[]) => void;
769
- }
770
-
771
- /**
772
- * Postprocessor functions
773
- */
774
- interface PostprocessorFunctions {
775
- postConstruct?: (this: PostprocessorInstance) => any;
776
- initialize?: (this: PostprocessorInstance, name: string, config: any) => void;
777
- process: (this: PostprocessorInstance, document: Document, output: string) => any;
778
- }
779
-
780
- interface PostprocessorInstance extends Postprocessor {
781
- [key: string]: any;
782
-
783
- super: (...params: any[]) => void;
784
- }
785
-
786
- /**
787
- * Preprocessor functions
788
- */
789
- interface PreprocessorFunctions {
790
- postConstruct?: (this: PreprocessorInstance) => any;
791
- initialize?: (this: PreprocessorInstance, name: string, config: any) => void;
792
- process: (this: PreprocessorInstance, document: Document, reader: Reader) => any;
793
- }
794
-
795
- interface PreprocessorInstance extends Preprocessor {
796
- [key: string]: any;
797
-
798
- super: (...params: any[]) => void;
799
- }
800
-
801
- /**
802
- * Docinfo processor functions
803
- */
804
- interface DocinfoProcessorFunctions {
805
- postConstruct?: (this: DocinfoProcessorInstance) => any;
806
- initialize?: (this: DocinfoProcessorInstance, name: string, config: any) => void;
807
- process: (this: DocinfoProcessorInstance, parent: Document, reader: Reader) => any;
808
- }
809
-
810
- interface DocinfoProcessorInstance extends DocinfoProcessor {
811
- [key: string]: any;
812
-
813
- super: (...params: any[]) => void;
814
- }
815
-
816
- /**
817
- * Block processor functions
818
- */
819
- interface BlockProcessorFunctions {
820
- postConstruct?: (this: BlockProcessorInstance) => any;
821
- initialize?: (this: BlockProcessorInstance, name: string, config: any) => void;
822
- process: (this: BlockProcessorInstance, parent: Document, reader: Reader, attributes?: any) => any;
823
- }
824
-
825
- interface BlockProcessorInstance extends BlockProcessor {
826
- [key: string]: any;
827
-
828
- super: (...params: any[]) => void;
829
- }
830
-
831
- /**
832
- * Block macro functions
833
- */
834
- interface BlockMacroFunctions {
835
- postConstruct?: (this: BlockMacroProcessorInstance) => any;
836
- initialize?: (this: BlockMacroProcessorInstance, name: string, config: any) => void;
837
- process: (this: BlockMacroProcessorInstance, parent: Document, target: string, attributes?: any) => any;
838
- }
839
-
840
- interface BlockMacroProcessorInstance extends BlockMacroProcessor {
841
- [key: string]: any;
842
-
843
- super: (...params: any[]) => void;
844
- }
845
-
846
- /**
847
- * Inline macro functions
848
- */
849
- interface InlineMacroFunctions {
850
- postConstruct?: (this: InlineMacroProcessorInstance) => any;
851
- initialize?: (this: InlineMacroProcessorInstance, name: string, config: any) => void;
852
- process: (this: InlineMacroProcessorInstance, parent: Document, target: string, attributes?: any) => any;
853
- }
854
-
855
- interface InlineMacroProcessorInstance extends InlineMacroProcessor {
856
- [key: string]: any;
857
-
858
- super: (...params: any[]) => void;
859
- }
860
-
861
- /**
862
- * Create a new {@link Registry}.
863
- * @param [name] - An optional name
864
- * @param [block] - An optional block
865
- * @returns a {@link Registry}
866
- */
867
- function create(name?: string, block?: (this: Registry) => any): Registry;
868
-
869
- /**
870
- */
871
- function register(block?: (this: Registry) => any): void;
872
-
873
- /**
874
- * Get statically-registered extension groups.
875
- */
876
- function getGroups(): object;
877
-
878
- /**
879
- * Unregister all statically-registered extension groups.
880
- */
881
- function unregisterAll(): void;
882
-
883
- /**
884
- * Unregister the specified statically-registered extension groups.
885
- *
886
- * NOTE Opal cannot delete an entry from a Hash that is indexed by symbol, so
887
- * we have to resort to using low-level operations in this method.
888
- */
889
- function unregister(...names: string[]): void;
890
-
891
- /**
892
- * Create a postprocessor
893
- * @description this API is experimental and subject to change
894
- */
895
- function createPostprocessor(arg: string | PostprocessorFunctions): PostprocessorKlass;
896
-
897
- /**
898
- * Create a postprocessor
899
- * @description this API is experimental and subject to change
900
- */
901
- function createPostprocessor(name: string, functions: PostprocessorFunctions): PostprocessorKlass;
902
-
903
- /**
904
- * Create and instantiate a postprocessor
905
- * @description this API is experimental and subject to change
906
- */
907
- function newPostprocessor(arg: string | PostprocessorFunctions): Postprocessor;
908
- /**
909
- * Create and instantiate a postprocessor
910
- * @description this API is experimental and subject to change
911
- */
912
- function newPostprocessor(name: string, functions: PostprocessorFunctions): Postprocessor;
913
-
914
- /**
915
- * Create a preprocessor
916
- * @description this API is experimental and subject to change
917
- */
918
- function createPreprocessor(arg: string | PreprocessorFunctions): PreprocessorKlass;
919
-
920
- /**
921
- * Create a preprocessor
922
- * @description this API is experimental and subject to change
923
- */
924
- function createPreprocessor(name: string, functions: PreprocessorFunctions): PreprocessorKlass;
925
-
926
- /**
927
- * Create and instantiate a preprocessor
928
- * @description this API is experimental and subject to change
929
- */
930
- function newPreprocessor(arg: string | PreprocessorFunctions): Preprocessor;
931
-
932
- /**
933
- * Create and instantiate a preprocessor
934
- * @description this API is experimental and subject to change
935
- */
936
- function newPreprocessor(name: string, functions: PreprocessorFunctions): Preprocessor;
937
-
938
- /**
939
- * Create a tree processor
940
- * @description this API is experimental and subject to change
941
- */
942
- function createTreeProcessor(arg: string | TreeProcessorFunctions): TreeProcessorKlass;
943
-
944
- /**
945
- * Create a tree processor
946
- * @description this API is experimental and subject to change
947
- */
948
- function createTreeProcessor(name: string, functions: TreeProcessorFunctions): TreeProcessorKlass;
949
-
950
- /**
951
- * Create and instantiate a tree processor
952
- * @description this API is experimental and subject to change
953
- */
954
- function newTreeProcessor(arg: string | TreeProcessorFunctions): TreeProcessor;
955
-
956
- /**
957
- * Create and instantiate a tree processor
958
- * @description this API is experimental and subject to change
959
- */
960
- function newTreeProcessor(name: string, functions: TreeProcessorFunctions): TreeProcessor;
961
-
962
- /**
963
- * Create an include processor
964
- * @description this API is experimental and subject to change
965
- */
966
- function createIncludeProcessor(arg: string | IncludeProcessorFunctions): IncludeProcessorKlass;
967
-
968
- /**
969
- * Create an include processor
970
- * @description this API is experimental and subject to change
971
- */
972
- function createIncludeProcessor(name: string, functions: IncludeProcessorFunctions): IncludeProcessorKlass;
973
-
974
- /**
975
- * Create and instantiate an include processor
976
- * @description this API is experimental and subject to change
977
- */
978
- function newIncludeProcessor(arg: string | IncludeProcessorFunctions): IncludeProcessor;
979
-
980
- /**
981
- * Create and instantiate an include processor
982
- * @description this API is experimental and subject to change
983
- */
984
- function newIncludeProcessor(name: string, functions: IncludeProcessorFunctions): IncludeProcessor;
985
-
986
- /**
987
- * Create a Docinfo processor
988
- * @description this API is experimental and subject to change
989
- */
990
- function createDocinfoProcessor(arg: string | DocinfoProcessorFunctions): DocinfoProcessorKlass;
991
-
992
- /**
993
- * Create a Docinfo processor
994
- * @description this API is experimental and subject to change
995
- */
996
- function createDocinfoProcessor(name: string, functions: DocinfoProcessorFunctions): DocinfoProcessorKlass;
997
-
998
- /**
999
- * Create and instantiate a Docinfo processor
1000
- * @description this API is experimental and subject to change
1001
- */
1002
- function newDocinfoProcessor(arg: string | DocinfoProcessorFunctions): DocinfoProcessor;
1003
-
1004
- /**
1005
- * Create and instantiate a Docinfo processor
1006
- * @description this API is experimental and subject to change
1007
- */
1008
- function newDocinfoProcessor(name: string, functions: DocinfoProcessorFunctions): DocinfoProcessor;
1009
-
1010
- /**
1011
- * Create a block processor
1012
- * @description this API is experimental and subject to change
1013
- */
1014
- function createBlockProcessor(arg: string | BlockProcessorFunctions): BlockProcessorKlass;
1015
-
1016
- /**
1017
- * Create a block processor
1018
- * @description this API is experimental and subject to change
1019
- */
1020
- function createBlockProcessor(name: string, functions: BlockProcessorFunctions): BlockProcessorKlass;
1021
-
1022
- /**
1023
- * Create and instantiate a block processor
1024
- * @description this API is experimental and subject to change
1025
- */
1026
- function newBlockProcessor(arg: string | BlockProcessorFunctions): BlockProcessor;
1027
-
1028
- /**
1029
- * Create and instantiate a block processor
1030
- * @description this API is experimental and subject to change
1031
- */
1032
- function newBlockProcessor(name: string, functions: BlockProcessorFunctions): BlockProcessor;
1033
-
1034
- /**
1035
- * Create an inline macro processor
1036
- * @description this API is experimental and subject to change
1037
- */
1038
- function createInlineMacroProcessor(arg: string | InlineMacroFunctions): InlineMacroProcessorKlass;
1039
-
1040
- /**
1041
- * Create an inline macro processor
1042
- * @description this API is experimental and subject to change
1043
- */
1044
- function createInlineMacroProcessor(name: string, functions: InlineMacroFunctions): InlineMacroProcessorKlass;
1045
-
1046
- /**
1047
- * Create and instantiate an inline macro processor
1048
- * @description this API is experimental and subject to change
1049
- */
1050
- function newInlineMacroProcessor(arg: string | InlineMacroFunctions): InlineMacroProcessor;
1051
-
1052
- /**
1053
- * Create and instantiate an inline macro processor
1054
- * @description this API is experimental and subject to change
1055
- */
1056
- function newInlineMacroProcessor(name: string, functions: InlineMacroFunctions): InlineMacroProcessor;
1057
-
1058
- /**
1059
- * Create a block macro processor
1060
- * @description this API is experimental and subject to change
1061
- */
1062
- function createBlockMacroProcessor(arg: string | BlockMacroFunctions): BlockMacroProcessorKlass;
1063
-
1064
- /**
1065
- * Create a block macro processor
1066
- * @description this API is experimental and subject to change
1067
- */
1068
- function createBlockMacroProcessor(name: string, functions: BlockMacroFunctions): BlockMacroProcessorKlass;
1069
-
1070
- /**
1071
- * Create and instantiate a block macro processor
1072
- * @description this API is experimental and subject to change
1073
- */
1074
- function newBlockMacroProcessor(arg: string | BlockMacroFunctions): BlockMacroProcessor;
1075
-
1076
- /**
1077
- * Create and instantiate a block macro processor
1078
- * @description this API is experimental and subject to change
1079
- */
1080
- function newBlockMacroProcessor(name: string, functions: BlockMacroFunctions): BlockMacroProcessor;
1081
-
1082
- class Registry {
1083
- /**
1084
- * Get extension groups.
1085
- */
1086
- getGroups(): any;
1087
-
1088
- unregisterAll(): void;
1089
-
1090
- unregister(...names: string[]): void;
1091
-
1092
- prefer(name: string, processor: any): void;
1093
-
1094
- block(name: string, processor: ((this: BlockProcessorDsl) => void | typeof BlockProcessorKlass | BlockProcessor)): void;
1095
- block(processor: ((this: BlockProcessorDsl) => void) | typeof BlockProcessorKlass | BlockProcessor): void;
1096
-
1097
- inlineMacro(name: string, processor: ((this: InlineMacroProcessorDsl) => void) | typeof InlineMacroProcessorKlass | InlineMacroProcessor): void;
1098
- inlineMacro(processor: ((this: InlineMacroProcessorDsl) => void) | typeof InlineMacroProcessorKlass | InlineMacroProcessor): void;
1099
-
1100
- blockMacro(name: string, processor: ((this: BlockMacroProcessorDsl) => void) | typeof BlockMacroProcessorKlass | BlockMacroProcessor): void;
1101
- blockMacro(processor: ((this: BlockMacroProcessorDsl) => void) | typeof BlockMacroProcessorKlass | BlockMacroProcessor): void;
1102
-
1103
- includeProcessor(processor: ((this: IncludeProcessorDsl) => void) | typeof IncludeProcessorKlass | IncludeProcessor): void;
1104
-
1105
- treeProcessor(processor: ((this: TreeProcessorDsl) => void) | typeof TreeProcessorKlass | TreeProcessor): void;
1106
-
1107
- postprocessor(processor: ((this: PostprocessorDsl) => void) | typeof PostprocessorKlass | Postprocessor): void;
1108
-
1109
- preprocessor(processor: ((this: PreprocessorDsl) => void) | typeof PreprocessorKlass | Preprocessor): void;
1110
-
1111
- docinfoProcessor(processor: ((this: DocinfoProcessorDsl) => void) | typeof DocinfoProcessorKlass | DocinfoProcessor): void;
1112
-
1113
- /**
1114
- * Checks whether any {{@link Extensions/Preprocessor}} extensions have been registered.
1115
- *
1116
- * @returns a {boolean} indicating whether any {{@link Extensions/Preprocessor}} extensions are registered.
1117
- */
1118
- hasPreprocessors(): boolean;
1119
-
1120
- /**
1121
- * Checks whether any {{@link Extensions/TreeProcessor}} extensions have been registered.
1122
- *
1123
- * @returns a {boolean} indicating whether any {{@link Extensions/TreeProcessor}} extensions are registered.
1124
- */
1125
- hasTreeProcessors(): boolean;
1126
-
1127
- /**
1128
- * Checks whether any {{@link Extensions/IncludeProcessor}} extensions have been registered.
1129
- *
1130
- * @returns a {boolean} indicating whether any {{@link Extensions/IncludeProcessor}} extensions are registered.
1131
- */
1132
- hasIncludeProcessors(): boolean;
1133
-
1134
- /**
1135
- * Checks whether any {{@link Extensions/Postprocessor}} extensions have been registered.
1136
- *
1137
- * @returns a {boolean} indicating whether any {{@link Extensions/Postprocessor}} extensions are registered.
1138
- */
1139
- hasPostprocessors(): boolean;
1140
-
1141
- /**
1142
- * Checks whether any {{@link Extensions/DocinfoProcessor}} extensions have been registered.
1143
- *
1144
- * @param location - A for selecting docinfo extensions at a given location (head or footer) (default: undefined)
1145
- * @returns a {boolean} indicating whether any {{@link Extensions/DocinfoProcessor}} extensions are registered.
1146
- */
1147
- hasDocinfoProcessors(location?: string): boolean;
1148
-
1149
- /**
1150
- * Checks whether any {{@link Extensions/BlockProcessor}} extensions have been registered.
1151
- *
1152
- * @returns a {boolean} indicating whether any {{@link Extensions/BlockProcessor}} extensions are registered.
1153
- */
1154
- hasBlocks(): boolean;
1155
-
1156
- /**
1157
- * Checks whether any {{@link Extensions/BlockMacroProcessor}} extensions have been registered.
1158
- *
1159
- * @returns a {boolean} indicating whether any {{@link Extensions/BlockMacroProcessor}} extensions are registered.
1160
- */
1161
- hasBlockMacros(): boolean;
1162
-
1163
- /**
1164
- * Checks whether any {{@link Extensions/InlineMacroProcessor}} extensions have been registered.
1165
- *
1166
- * @returns a {boolean} indicating whether any {{@link Extensions/InlineMacroProcessor}} extensions are registered.
1167
- */
1168
- hasInlineMacros(): boolean;
1169
-
1170
- /**
1171
- * Retrieves the Extension proxy objects for all the {{@link Extensions/Preprocessor}} instances stored in this registry.
1172
- *
1173
- * @returns an {array} of Extension proxy objects.
1174
- */
1175
- getPreprocessors(): Preprocessor[];
1176
-
1177
- /**
1178
- * Retrieves the Extension proxy objects for all the {{@link Extensions/TreeProcessor}} instances stored in this registry.
1179
- *
1180
- * @returns an {array} of Extension proxy objects.
1181
- */
1182
- getTreeProcessors(): TreeProcessor[];
1183
-
1184
- /**
1185
- * Retrieves the Extension proxy objects for all the {{@link Extensions/IncludeProcessor}} instances stored in this registry.
1186
- *
1187
- * @returns an {array} of Extension proxy objects.
1188
- */
1189
- getIncludeProcessors(): IncludeProcessor[];
1190
-
1191
- /**
1192
- * Retrieves the Extension proxy objects for all the {{@link Extensions/Postprocessor}} instances stored in this registry.
1193
- *
1194
- * @returns an {array} of Extension proxy objects.
1195
- */
1196
- getPostprocessors(): Postprocessor[];
1197
-
1198
- /**
1199
- * Retrieves the Extension proxy objects for all the {{@link Extensions/DocinfoProcessor}} instances stored in this registry.
1200
- *
1201
- * @param location - A {string} for selecting docinfo extensions at a given location (head or footer) (default: undefined)
1202
- * @returns an {array} of Extension proxy objects.
1203
- */
1204
- getDocinfoProcessors(location?: string): DocinfoProcessor[];
1205
-
1206
- /**
1207
- * Retrieves the Extension proxy objects for all the {{@link Extensions/BlockProcessor}} instances stored in this registry.
1208
- *
1209
- * @returns an {array} of Extension proxy objects.
1210
- */
1211
- getBlocks(): BlockProcessor[];
1212
-
1213
- /**
1214
- * Retrieves the Extension proxy objects for all the {{@link Extensions/BlockMacroProcessor}} instances stored in this registry.
1215
- *
1216
- * @returns an {array} of Extension proxy objects.
1217
- */
1218
- getBlockMacros(): BlockMacroProcessor[];
1219
-
1220
- /**
1221
- * Retrieves the Extension proxy objects for all the {{@link Extensions/InlineMacroProcessor}} instances stored in this registry.
1222
- *
1223
- * @returns an {array} of Extension proxy objects.
1224
- */
1225
- getInlineMacros(): InlineMacroProcessor[];
1226
-
1227
- /**
1228
- * Get any {{@link Extensions/InlineMacroProcessor}} extensions are registered to handle the specified inline macro name.
1229
- *
1230
- * @param name - the {string} inline macro name
1231
- * @returns the Extension proxy object for the {{@link Extensions/InlineMacroProcessor}} that matches the inline macro name or undefined if no match is found.
1232
- */
1233
- getInlineMacroFor(name: string): InlineMacroProcessor | undefined;
1234
-
1235
- /**
1236
- * Get any {{@link Extensions/BlockProcessor}} extensions are registered to handle the specified block name appearing on the specified context.
1237
- * @param name - the {string} block name
1238
- * @param context - the context of the block: paragraph, open... (optional)
1239
- * @returns the Extension proxy object for the {{@link Extensions/BlockProcessor}} that matches the block name and context or undefined if no match is found.
1240
- */
1241
- getBlockFor(name: string, context?: string): BlockProcessor | undefined;
1242
-
1243
- /**
1244
- * Get any {{@link Extensions/BlockMacroProcessor}} extensions are registered to handle the specified macro name.
1245
- *
1246
- * @param name - the {string} macro name
1247
- * @returns the Extension proxy object for the {{@link Extensions/BlockMacroProcessor}} that matches the macro name or undefined if no match is found.
1248
- */
1249
- getBlockMacroFor(name: string): BlockMacroProcessor | undefined;
1250
- }
1251
-
1252
- class Processor {
1253
- constructor(config?: any);
1254
-
1255
- /**
1256
- * Creates a list block node and links it to the specified parent.
1257
- * @param parent - The parent Block (Block, Section, or Document) of this new list block.
1258
- * @param context - The list context (e.g., ulist, olist, colist, dlist)
1259
- * @param attrs - An object of attributes to set on this list block
1260
- * @returns a {List}
1261
- */
1262
- createList(parent: AbstractBlock, context: string, attrs?: any): List;
1263
-
1264
- /**
1265
- * Creates a list item node and links it to the specified parent.
1266
- * @param parent - The parent {List} of this new list item block.
1267
- * @param text - The text of the list item.
1268
- * @returns a {ListItem}
1269
- */
1270
- createListItem(parent: List, text?: string): ListItem;
1271
-
1272
- /**
1273
- * Creates an image block node and links it to the specified parent.
1274
- * @param parent - The parent Block of this new image block.
1275
- * @param attrs - A JSON of attributes
1276
- * @param attrs.target - the target attribute to set the source of the image.
1277
- * @param attrs.alt - the alt attribute to specify an alternative text for the image.
1278
- * @param opts - A JSON of options
1279
- * @returns an image {Block}
1280
- */
1281
- createImageBlock(parent: AbstractBlock, attrs: Image.Attributes, opts?: Block.Options): Block;
1282
-
1283
- /**
1284
- * Creates a paragraph block and links it to the specified parent.
1285
- * @param parent - The parent Block (Block, Section, or Document) of this new block.
1286
- * @param source - The source
1287
- * @param attrs - An object of attributes to set on this block
1288
- * @param opts - An object of options to set on this block
1289
- */
1290
- createParagraph(parent: AbstractBlock, source: string | string[], attrs?: any, opts?: Block.Options): Block;
1291
-
1292
- /**
1293
- * Creates an open block and links it to the specified parent.
1294
- * @param parent - The parent Block (Block, Section, or Document) of this new block.
1295
- * @param source - The source
1296
- * @param attrs - An object of attributes to set on this block
1297
- * @param opts - An object of options to set on this block
1298
- */
1299
- createOpenBlock(parent: AbstractBlock, source?: string | string[], attrs?: any, opts?: Block.Options): Block;
1300
-
1301
- /**
1302
- * Creates an example block and links it to the specified parent.
1303
- * @param parent - The parent Block (Block, Section, or Document) of this new block.
1304
- * @param source - The source
1305
- * @param attrs - An object of attributes to set on this block
1306
- * @param opts - An object of options to set on this block
1307
- */
1308
- createExampleBlock(parent: AbstractBlock, source: string | string[], attrs?: any, opts?: Block.Options): Block;
1309
-
1310
- /**
1311
- * Creates a pass block and links it to the specified parent.
1312
- * @param parent - The parent Block (Block, Section, or Document) of this new block.
1313
- * @param source - The source
1314
- * @param attrs - An object of attributes to set on this block
1315
- * @param opts - An object of options to set on this block
1316
- */
1317
- createPassBlock(parent: AbstractBlock, source: string | string[], attrs?: any, opts?: Block.Options): Block;
1318
-
1319
- /**
1320
- * Creates a listing block and links it to the specified parent.
1321
- * @param parent - The parent Block (Block, Section, or Document) of this new block.
1322
- * @param source - The source
1323
- * @param attrs - An object of attributes to set on this block
1324
- * @param opts - An object of options to set on this block
1325
- */
1326
- createListingBlock(parent: AbstractBlock, source: string | string[], attrs?: any, opts?: Block.Options): Block;
1327
-
1328
- /**
1329
- * Creates a literal block and links it to the specified parent.
1330
- * @param parent - The parent Block (Block, Section, or Document) of this new block.
1331
- * @param source - The source
1332
- * @param attrs - An object of attributes to set on this block
1333
- * @param opts - An object of options to set on this block
1334
- */
1335
- createLiteralBlock(parent: AbstractBlock, source: string | string[], attrs?: any, opts?: Block.Options): Block;
1336
-
1337
- /**
1338
- * Creates a block and links it to the specified parent.
1339
- * @param parent - The parent Block (Block, Section, or Document) of this new block.
1340
- * @param context - The context name
1341
- * @param source - The source
1342
- * @param attrs - An object of attributes to set on this block
1343
- * @param opts - An object of options to set on this block
1344
- */
1345
- createBlock(parent: AbstractBlock, context: string, source: string | string[], attrs?: any, opts?: Block.Options): Block;
1346
-
1347
- /**
1348
- * Creates an inline anchor and links it to the specified parent.
1349
- * @param parent - The parent Block (Block, Section, or Document) of this new block.
1350
- * @param text - The text
1351
- * @param opts - An object of options to set on this block
1352
- * @returns an {Inline} anchor
1353
- */
1354
- createAnchor(parent: AbstractBlock, text: string, opts?: Inline.Options): Inline;
1355
-
1356
- /**
1357
- * Creates an inline pass and links it to the specified parent.
1358
- * @param parent - The parent Block (Block, Section, or Document) of this new block.
1359
- * @param text - The text
1360
- * @param opts - An object of options to set on this block
1361
- * @returns an {Inline} pass
1362
- */
1363
- createInlinePass(parent: AbstractBlock, text: string, opts?: Inline.Options): Inline;
1364
-
1365
- /**
1366
- * Creates an inline node and links it to the specified parent.
1367
- * @param parent - The parent Block of this new inline node.
1368
- * @param context - The context name
1369
- * @param text - The text
1370
- * @param opts - A JSON of options
1371
- * @returns an {Inline} node
1372
- */
1373
- createInline(parent: AbstractBlock, context: string, text: string, opts?: Inline.Options): Inline;
1374
-
1375
- /**
1376
- * Parses blocks in the content and attaches the block to the parent.
1377
- * @param parent - the parent block
1378
- * @param content - the content
1379
- * @param attrs - an object of attributes
1380
- * @returns The parent node into which the blocks are parsed.
1381
- */
1382
- parseContent(parent: AbstractBlock, content: string | string[], attrs?: any): AbstractNode;
1383
-
1384
- /**
1385
- * Parses the attrlist String into a JSON of attributes
1386
- * @param block - the current AbstractBlock or the parent AbstractBlock if there is no current block (used for applying subs)
1387
- * @param attrlist - the list of attributes as a String
1388
- * @param opts - an optional JSON of options to control processing:
1389
- * - positional_attributes: an Array of attribute names to map positional arguments to (optional, default: [])
1390
- * - sub_attributes: enables attribute substitution on the attrlist argument (optional, default: false)
1391
- * @returns a JSON of parsed attributes
1392
- */
1393
- parseAttributes(block: AbstractBlock, attrlist: string, opts?: ParseAttributesOptions): Attributes;
1394
-
1395
- /**
1396
- * Get the configuration JSON for this processor instance.
1397
- */
1398
- getConfig(): Options;
1399
- }
1400
-
1401
- class ProcessorDsl {
1402
- option(key: string, value: any): void;
1403
- }
1404
-
1405
- class MacroProcessor extends Processor {
1406
- constructor(name?: string, config?: any);
1407
-
1408
- getName(): string;
1409
-
1410
- process(parent: Document, target: string, attributes?: any): any;
1411
- }
1412
-
1413
- class BlockProcessor extends Processor {
1414
- constructor(name?: string, config?: any);
1415
-
1416
- getName(): string;
1417
-
1418
- process(parent: Document, reader: Reader, attributes?: any): any;
1419
- }
1420
-
1421
- class BlockMacroProcessor extends MacroProcessor {
1422
- }
1423
-
1424
- class InlineMacroProcessor extends MacroProcessor {
1425
- }
1426
-
1427
- class InlineMacroProcessorDsl extends MacroProcessorDsl {
1428
- parseContentAs(value: string): void;
1429
-
1430
- matchFormat(value: string): void;
1431
-
1432
- match(value: RegExp): void;
1433
-
1434
- process(block: (this: InlineMacroProcessor, parent: Document, target: string, attributes: any) => void): void;
1435
- }
1436
-
1437
- class IncludeProcessor {
1438
- process(this: IncludeProcessor, document: Document, reader: Reader, target: string, attributes: any): void;
1439
- }
1440
-
1441
- class TreeProcessor extends Processor {
1442
- process(this: TreeProcessor, document: Document): any;
1443
- }
1444
-
1445
- class Postprocessor extends Processor {
1446
- process(this: Postprocessor, document: Document, output: string): any;
1447
- }
1448
-
1449
- class Preprocessor extends Processor {
1450
- process(this: Preprocessor, document: Document, reader: Reader): any;
1451
- }
1452
-
1453
- class DocinfoProcessor extends Processor {
1454
- process(this: DocinfoProcessor, document: Document): any;
1455
- }
1456
-
1457
- // OpalKlass
1458
- class BlockProcessorKlass extends OpalKlass<BlockProcessor> {
1459
- }
1460
-
1461
- class BlockMacroProcessorKlass extends OpalKlass<BlockMacroProcessor> {
1462
- }
1463
-
1464
- class InlineMacroProcessorKlass extends OpalKlass<InlineMacroProcessor> {
1465
- }
1466
-
1467
- class TreeProcessorKlass extends OpalKlass<TreeProcessor> {
1468
- }
1469
-
1470
- class IncludeProcessorKlass extends OpalKlass<IncludeProcessor> {
1471
- }
1472
-
1473
- class PostprocessorKlass extends OpalKlass<Postprocessor> {
1474
- }
1475
-
1476
- class PreprocessorKlass extends OpalKlass<Preprocessor> {
1477
- }
1478
-
1479
- class DocinfoProcessorKlass extends OpalKlass<DocinfoProcessor> {
1480
- }
1481
-
1482
- // DSL
1483
- abstract class SyntaxProcessorDsl extends ProcessorDsl {
1484
- named(name: string): void;
1485
-
1486
- defaultAttributes(value: any): void;
1487
-
1488
- positionalAttributes(value: string[]): void;
1489
-
1490
- positionalAttributes(...value: string[]): void;
1491
-
1492
- /**
1493
- * Specify how to resolve attributes.
1494
- * @param [value] - A specification to resolve attributes.
1495
- */
1496
- resolveAttributes(value?: string | string[] | object | boolean): void;
1497
- }
1498
-
1499
- class MacroProcessorDsl extends SyntaxProcessorDsl {
1500
- /**
1501
- * Specify how to resolve attributes.
1502
- * @param [value] - A specification to resolve attributes.
1503
- */
1504
- resolveAttributes(value?: string | string[] | object | boolean): void;
1505
- }
1506
-
1507
- class BlockProcessorDsl extends SyntaxProcessorDsl {
1508
- onContext(context: string | string[]): void;
1509
-
1510
- onContexts(...contexts: string[]): void;
1511
-
1512
- parseContentAs(value: string): void;
1513
-
1514
- process(block: (this: BlockProcessor, parent: Document, reader: Reader, attributes: any) => void): void;
1515
- }
1516
-
1517
- class BlockMacroProcessorDsl extends MacroProcessorDsl {
1518
- parseContentAs(value: string): void;
1519
-
1520
- process(block: (this: BlockMacroProcessor, parent: Document, target: string, attributes: any) => void): void;
1521
- }
1522
-
1523
- class IncludeProcessorDsl {
1524
- process(block: (this: IncludeProcessor, document: Document, reader: Reader, target: string, attributes: any) => void): void;
1525
-
1526
- handles(block: (target: string) => boolean): void;
1527
-
1528
- prefer(): void;
1529
- }
1530
-
1531
- class DocumentProcessorDsl {
1532
- prefer(): void;
1533
- }
1534
-
1535
- class TreeProcessorDsl extends DocumentProcessorDsl {
1536
- process(block: (this: TreeProcessor, document: Document) => void): void;
1537
- }
1538
-
1539
- class PostprocessorDsl extends DocumentProcessorDsl {
1540
- process(block: (this: Postprocessor, document: Document, output: string) => void): void;
1541
- }
1542
-
1543
- class PreprocessorDsl extends DocumentProcessorDsl {
1544
- process(block: (this: Preprocessor, document: Document, reader: Reader) => void): void;
1545
- }
1546
-
1547
- class DocinfoProcessorDsl extends DocumentProcessorDsl {
1548
- atLocation(location: string): void;
1549
-
1550
- process(block: (this: DocinfoProcessor, document: Document) => void): void;
1551
- }
1552
- }
1553
-
1554
- /**
1555
- * The {@link Document} class represents a parsed AsciiDoc document.
1556
- *
1557
- * Document is the root node of a parsed AsciiDoc document.<br/>
1558
- * It provides an abstract syntax tree (AST) that represents the structure of the AsciiDoc document
1559
- * from which the Document object was parsed.
1560
- *
1561
- * Although the constructor can be used to create an empty document object,
1562
- * more commonly, you'll load the document object from AsciiDoc source
1563
- * using the primary API methods on {@link Asciidoctor}.
1564
- * When using one of these APIs, you almost always want to set the safe mode to 'safe' (or 'unsafe')
1565
- * to enable all of Asciidoctor's features.
1566
- *
1567
- * <pre>
1568
- * var doc = load('= Hello, AsciiDoc!', { 'safe': 'safe' })
1569
- * // => Asciidoctor::Document { doctype: "article", doctitle: "Hello, AsciiDoc!", blocks: 0 }
1570
- * </pre>
1571
- *
1572
- * Instances of this class can be used to extract information from the document or alter its structure.
1573
- * As such, the Document object is most often used in extensions and by integrations.
1574
- *
1575
- * The most basic usage of the Document object is to retrieve the document's title.
1576
- *
1577
- * <pre>
1578
- * var source = '= Document Title'
1579
- * var doc = asciidoctor.load(source, { 'safe': 'safe' })
1580
- * console.log(doc.getTitle()) // 'Document Title'
1581
- * </pre>
1582
- *
1583
- * You can also use the Document object to access document attributes defined in the header, such as the author and doctype.
1584
- */
1585
- export class Document extends AbstractBlock {
1586
- /**
1587
- * Returns the SyntaxHighlighter associated with this document.
1588
- *
1589
- * @returns the {SyntaxHighlighter} associated with this document.
1590
- */
1591
- getSyntaxHighlighter(): SyntaxHighlighter;
1592
-
1593
- /**
1594
- * Returns a JSON {Object} of references captured by the processor.
1595
- *
1596
- * @returns a JSON object of {AbstractNode} in the document.
1597
- */
1598
- getRefs(): any;
1599
-
1600
- /**
1601
- * Returns an {Array} of {Document/ImageReference} captured by the processor.
1602
- *
1603
- * @returns an {Array} of {Document/ImageReference} in the document.
1604
- * Will return an empty array if the option "catalog_assets: true" was not defined on the processor.
1605
- */
1606
- getImages(): Document.ImageReference[];
1607
-
1608
- /**
1609
- * Returns an {Array} of links captured by the processor.
1610
- *
1611
- * @returns an {Array} of links in the document.
1612
- * Will return an empty array if:
1613
- * - the function was called before the document was converted
1614
- * - the option "catalog_assets: true" was not defined on the processor
1615
- */
1616
- getLinks(): any[];
1617
-
1618
- /**
1619
- * @returns true if the document has footnotes otherwise false
1620
- */
1621
- hasFootnotes(): boolean;
1622
-
1623
- /**
1624
- * Returns an {Array} of {Document/Footnote} captured by the processor.
1625
- *
1626
- * @returns an {Array} of {Document/Footnote} in the document.
1627
- * Will return an empty array if the function was called before the document was converted.
1628
- */
1629
- getFootnotes(): Document.Footnote[];
1630
-
1631
- /**
1632
- * Returns the level-0 {Section} (i.e. the document title).
1633
- * Only stores the title, not the header attributes.
1634
- *
1635
- * @returns the level-0 {Section}.
1636
- */
1637
- getHeader(): string;
1638
-
1639
- /**
1640
- * @param [options] - a JSON of options to control processing (default: {})
1641
- */
1642
- convert(options?: object): string;
1643
-
1644
- /**
1645
- * Write the output to the specified file.
1646
- *
1647
- * If the converter responds to "write", delegate the work of writing the file to that method.
1648
- * Otherwise, write the output the specified file.
1649
- */
1650
- write(output: string, target: string): void;
1651
-
1652
- /**
1653
- * @returns the full name of the author as a String
1654
- */
1655
- getAuthor(): string;
1656
-
1657
- getSource(): string;
1658
-
1659
- getSourceLines(): string[];
1660
-
1661
- isNested(): boolean;
1662
-
1663
- isEmbedded(): boolean;
1664
-
1665
- hasExtensions(): boolean;
1666
-
1667
- getDoctype(): string;
1668
-
1669
- getBackend(): string;
1670
-
1671
- isBasebackend(): boolean;
1672
-
1673
- /**
1674
- * Return the document title as a {string}
1675
- *
1676
- * @returns the resolved document title as a {string} or undefined if a document title cannot be resolved
1677
- */
1678
- getTitle(): string | undefined;
1679
-
1680
- /**
1681
- * Set the title on the document header
1682
- *
1683
- * Set the title of the document header to the specified value.
1684
- * If the header does not exist, it is first created.
1685
- *
1686
- * @param title - the String title to assign as the title of the document header
1687
- *
1688
- * @returns the new String title assigned to the document header
1689
- */
1690
- setTitle(title: string): string;
1691
-
1692
- /**
1693
- * Resolves the primary title for the document
1694
- *
1695
- * Searches the locations to find the first non-empty value:
1696
- *
1697
- * - document-level attribute named title
1698
- * - header title (known as the document title)
1699
- * - title of the first section
1700
- * - document-level attribute named untitled-label (if use_fallback option is set)
1701
- *
1702
- * If no value can be resolved, undefined is returned.
1703
- *
1704
- * If the partition attribute is specified, the value is parsed into an {@link Document/Title} object.
1705
- * If the sanitize attribute is specified, XML elements are removed from the value.
1706
- *
1707
- *
1708
- * @returns the resolved title as a {@link Document/Title} if the partition option is passed
1709
- * or a {string} if not or undefined if no value can be resolved.
1710
- */
1711
- getDocumentTitle(options?: TitleOptions): string | Title | undefined;
1712
-
1713
- /**
1714
- * @see {@link Document#getDocumentTitle}
1715
- */
1716
- getDoctitle(options: TitleOptions): string | Title;
1717
-
1718
- /**
1719
- * Get the document catalog JSON object.
1720
- */
1721
- getCatalog(): object;
1722
-
1723
- /**
1724
- * @see Document#getCatalog
1725
- */
1726
- getReferences(): object;
1727
-
1728
- /**
1729
- * Get the document revision date from document header (document attribute <code>revdate</code>).
1730
- */
1731
- getRevisionDate(): string | undefined;
1732
-
1733
- /**
1734
- * @see Document#getRevisionDate
1735
- */
1736
- getRevdate(): string | undefined;
1737
-
1738
- /**
1739
- * Get the document revision number from document header (document attribute <code>revnumber</code>).
1740
- */
1741
- getRevisionNumber(): string | undefined;
1742
-
1743
- /**
1744
- * Get the document revision remark from document header (document attribute <code>revremark</code>).
1745
- */
1746
- getRevisionRemark(): string | undefined;
1747
-
1748
- /**
1749
- * Assign a value to the specified attribute in the document header.
1750
- *
1751
- * The assignment will be visible when the header attributes are restored,
1752
- * typically between processor phases (e.g., between parse and convert).
1753
- *
1754
- * @param name - The attribute name to assign
1755
- * @param value - The value to assign to the attribute (default: '')
1756
- * @param overwrite - A {boolean} indicating whether to assign the attribute
1757
- * if already present in the attributes Hash (default: true)
1758
- *
1759
- * @returns true if the assignment was performed otherwise false
1760
- */
1761
- setHeaderAttribute(name: string, value: any, overwrite: boolean): boolean;
1762
-
1763
- /**
1764
- * Convenience method to retrieve the authors of this document as an {Array} of {Document/Author} objects.
1765
- *
1766
- * This method is backed by the author-related attributes on the document.
1767
- *
1768
- * @returns an {Array} of {Document/Author} objects.
1769
- */
1770
- getAuthors(): Author[];
1771
-
1772
- /**
1773
- * @returns a {@link Document/RevisionInfo}
1774
- */
1775
- getRevisionInfo(): Document.RevisionInfo;
1776
-
1777
- /**
1778
- * @returns true if the document contains revision info, otherwise false
1779
- */
1780
- hasRevisionInfo(): boolean;
1781
-
1782
- /**
1783
- */
1784
- getNotitle(): boolean;
1785
-
1786
- /**
1787
- */
1788
- getNoheader(): boolean;
1789
-
1790
- /**
1791
- */
1792
- getNofooter(): boolean;
1793
-
1794
- /**
1795
- */
1796
- hasHeader(): boolean;
1797
-
1798
- /**
1799
- * Replay attribute assignments at the block level
1800
- *
1801
- * <i>This method belongs to an internal API that deals with how attributes are managed by the processor.</i>
1802
- * If you understand why this group of methods are necessary, and what they do, feel free to use them.
1803
- * <strong>However, keep in mind they are subject to change at any time.</strong>
1804
- *
1805
- * @param blockAttributes - a JSON of attributes
1806
- */
1807
- playbackAttributes(blockAttributes: Block.Attributes): void;
1808
-
1809
- /**
1810
- * Delete the specified attribute from the document if the name is not locked.
1811
- * If the attribute is locked, false is returned.
1812
- * Otherwise, the attribute is deleted.
1813
- *
1814
- * @param name - the String attribute name
1815
- *
1816
- * @returns true if the attribute was deleted, false if it was not because it's locked
1817
- */
1818
- deleteAttribute(name: string): boolean;
1819
-
1820
- /**
1821
- * Restore the attributes to the previously saved state (attributes in header).
1822
- */
1823
- restoreAttributes(): void;
1824
-
1825
- /**
1826
- * Determine if the attribute has been locked by being assigned in document options.
1827
- *
1828
- * @param key - The attribute key to check
1829
- *
1830
- * @returns true if the attribute is locked, false otherwise
1831
- */
1832
- isAttributeLocked(key: string): boolean;
1833
-
1834
- /**
1835
- * Parse the AsciiDoc source stored in the {Reader} into an abstract syntax tree.
1836
- *
1837
- * If the data parameter is not nil, create a new {PreprocessorReader} and assigned it to the reader property of this object.
1838
- * Otherwise, continue with the reader that was created when the {Document} was instantiated.
1839
- * Pass the reader to {Parser.parse} to parse the source data into an abstract syntax tree.
1840
- *
1841
- * If parsing has already been performed, this method returns without performing any processing.
1842
- *
1843
- * @param [data] - The optional replacement AsciiDoc source data as a String or String Array. (default: undefined)
1844
- *
1845
- * @returns this {Document}
1846
- */
1847
- parse(data?: string | string[]): Document;
1848
-
1849
- /**
1850
- * Read the docinfo file(s) for inclusion in the document template
1851
- *
1852
- * If the docinfo1 attribute is set, read the docinfo.ext file.
1853
- * If the docinfo attribute is set, read the doc-name.docinfo.ext file.
1854
- * If the docinfo2 attribute is set, read both files in that order.
1855
- *
1856
- * @param location - The Symbol location of the docinfo (e.g., head, footer, etc). (default: head)
1857
- * @param suffix - The suffix of the docinfo file(s).
1858
- * If not set, the extension will be set to the outfilesuffix. (default: undefined)
1859
- *
1860
- * @returns the contents of the docinfo file(s) or empty string if no files are found or the safe mode is secure or greater.
1861
- */
1862
- getDocinfo(location: string, suffix?: string): string;
1863
-
1864
- /**
1865
- * @param [docinfoLocation] - A {string} for checking docinfo extensions at a given location (head or footer) (default: head)
1866
- */
1867
- hasDocinfoProcessors(docinfoLocation?: string): boolean;
1868
-
1869
- /**
1870
- * Increment the specified counter and store it in the block's attributes.
1871
- *
1872
- * @param counterName - the String name of the counter attribute
1873
- * @param block - the {Block} on which to save the counter
1874
- *
1875
- * @returns the next number in the sequence for the specified counter
1876
- */
1877
- incrementAndStoreCounter(counterName: string, block: Block): number;
1878
-
1879
- /**
1880
- * Get the named counter and take the next number in the sequence.
1881
- *
1882
- * @param name - the String name of the counter
1883
- * @param seed - the initial value as a String or Integer
1884
- *
1885
- * @returns the next number in the sequence for the specified counter
1886
- */
1887
- counter(name: string, seed: string | number): number;
1888
-
1889
- /**
1890
- * A read-only integer value indicating the level of security that should be enforced while processing this document.
1891
- * The value must be set in the Document constructor using the "safe" option.
1892
- *
1893
- * A value of 0 (UNSAFE) disables any of the security features enforced by
1894
- *
1895
- * A value of 1 (SAFE) closely parallels safe mode in AsciiDoc.
1896
- * In particular, it prevents access to files which reside outside of the parent directory of the source file and disables any macro other than the include directive.
1897
- *
1898
- * A value of 10 (SERVER) disallows the document from setting attributes that would affect the conversion of the document,
1899
- * in addition to all the security features of SafeMode.SAFE.
1900
- * For instance, this level forbids changing the backend or source-highlighter using an attribute defined in the source document header.
1901
- * This is the most fundamental level of security for server deployments (hence the name).
1902
- *
1903
- * A value of 20 (SECURE) disallows the document from attempting to read files from the file system and including the contents of them into the document,
1904
- * in addition to all the security features of SafeMode.SECURE.
1905
- * In particular, it disallows use of the include::[] directive and the embedding of binary content (data uri), stylesheets and JavaScripts referenced by the document.
1906
- * (Asciidoctor and trusted extensions may still be allowed to embed trusted content into the document).
1907
- *
1908
- * Since Asciidoctor is aiming for wide adoption, 20 (SECURE) is the default value and is recommended for server deployments.
1909
- *
1910
- * A value of 100 (PARANOID) is planned to disallow the use of passthrough macros and prevents the document from setting any known attributes,
1911
- * in addition to all the security features of SafeMode.SECURE.
1912
- * Please note that this level is not currently implemented (and therefore not enforced)!
1913
- *
1914
- * @returns An integer value indicating the level of security
1915
- */
1916
- getSafe(): number;
1917
-
1918
- /**
1919
- * Get the Boolean AsciiDoc compatibility mode.
1920
- * Enabling this attribute activates the following syntax changes:
1921
- *
1922
- * * single quotes as constrained emphasis formatting marks
1923
- * * single backticks parsed as inline literal, formatted as monospace
1924
- * * single plus parsed as constrained, monospaced inline formatting
1925
- * * double plus parsed as constrained, monospaced inline formatting
1926
- */
1927
- getCompatMode(): boolean;
1928
-
1929
- /**
1930
- * Get the Boolean flag that indicates whether source map information should be tracked by the parser.
1931
- */
1932
- getSourcemap(): boolean;
1933
-
1934
- /**
1935
- * Set the Boolean flag that indicates whether source map information should be tracked by the parser.
1936
- */
1937
- setSourcemap(value: boolean): void;
1938
-
1939
- /**
1940
- * Get the JSON of document counters.
1941
- */
1942
- getCounters(): object;
1943
-
1944
- /**
1945
- */
1946
- getCallouts(): Callouts;
1947
-
1948
- /**
1949
- * Get the String base directory for converting this document.
1950
- *
1951
- * Defaults to directory of the source file.
1952
- * If the source is a string, defaults to the current directory.
1953
- */
1954
- getBaseDir(): string;
1955
-
1956
- /**
1957
- * Get the JSON of resolved options used to initialize this {Document}.
1958
- */
1959
- getOptions(): any;
1960
-
1961
- /**
1962
- * Get the outfilesuffix defined at the end of the header.
1963
- */
1964
- getOutfilesuffix(): string;
1965
-
1966
- /**
1967
- * Get a reference to the parent {Document} of this nested document.
1968
- */
1969
- getParentDocument(): Document | undefined;
1970
-
1971
- /**
1972
- * Get the {Reader} associated with this document.
1973
- */
1974
- getReader(): Reader;
1975
-
1976
- /**
1977
- * Get the {Converter} instance being used to convert the current {Document}.
1978
- */
1979
- getConverter(): AbstractConverter;
1980
-
1981
- /**
1982
- * Get the activated {Extensions.Registry} associated with this document.
1983
- */
1984
- getExtensions(): Registry;
1985
- }
1986
-
1987
- type ContentModel = 'compound' | 'simple' | 'verbatim' | 'raw' | 'empty'
1988
-
1989
- /**
1990
- */
1991
- export class AbstractBlock extends AbstractNode {
1992
-
1993
- /**
1994
- * Describes the type of content this block accepts and how it should be converted.
1995
- * @returns the type of content this block accepts.
1996
- */
1997
- getContentModel(): ContentModel
1998
-
1999
- /**
2000
- * Set the type of content this block accepts. Acceptable values are:
2001
- * - compound - this block contains other blocks
2002
- * - simple - this block holds a paragraph of prose that receives normal substitutions
2003
- * - verbatim - this block holds verbatim text (displayed "as is") that receives verbatim substitutions
2004
- * - raw - this block holds unprocessed content passed directly to the output with no substitutions applied
2005
- * - empty - this block has no content
2006
- * @param contentModel - the type of content
2007
- */
2008
- setContentModel(contentModel: ContentModel): void;
2009
-
2010
- /**
2011
- * Append a block to this block's list of child blocks.
2012
- * @param block - the block to append
2013
- * @returns the parent block to which this block was appended.
2014
- */
2015
- append(block: AbstractBlock): AbstractBlock;
2016
-
2017
- /**
2018
- * Get the String title of this Block with title substitions applied
2019
- *
2020
- * The following substitutions are applied to block and section titles:
2021
- *
2022
- * <code>specialcharacters</code>, <code>quotes</code>, <code>replacements</code>, <code>macros</code>, <code>attributes</code> and <code>post_replacements</code>
2023
- *
2024
- * @returns the converted String title for this Block, or undefined if the title is not set.
2025
- * @example
2026
- * block.title // "Foo 3^ # {two-colons} Bar(1)"
2027
- * block.getTitle(); // "Foo 3^ # :: Bar(1)"
2028
- */
2029
- getTitle(): string | undefined;
2030
-
2031
- /**
2032
- * Set the String block title.
2033
- * @param title - The document title
2034
- * @returns returns the new String title assigned to this Block.
2035
- */
2036
- setTitle(title: string | undefined): string;
2037
-
2038
- /**
2039
- * Generate and assign caption to block if not already assigned.
2040
- *
2041
- * If the block has a title and a caption prefix is available for this block,
2042
- * then build a caption from this information, assign it a number and store it
2043
- * to the caption attribute on the block.
2044
- *
2045
- * If a caption has already been assigned to this block, do nothing.
2046
- *
2047
- * The parts of a complete caption are: `<prefix> <number>. <title>`
2048
- * This partial caption represents the part the precedes the title.
2049
- *
2050
- * @param value - the String caption to assign to this block or nil to use document attribute.
2051
- * @param captionContext - the String context to use when resolving caption-related attributes.
2052
- * If not provided, the name of the context for this block is used. Only certain contexts allow the caption to be looked up.
2053
- */
2054
- assignCaption(value?: string, captionContext?: string): void;
2055
-
2056
- /**
2057
- * Convenience method that returns the interpreted title of the Block
2058
- * with the caption prepended.
2059
- * Concatenates the value of this Block's caption instance variable and the
2060
- * return value of this Block's title method. No space is added between the
2061
- * two values. If the Block does not have a caption, the interpreted title is
2062
- * returned.
2063
- *
2064
- * @returns the converted String title prefixed with the caption, or just the
2065
- * converted String title if no caption is set
2066
- */
2067
- getCaptionedTitle(): string;
2068
-
2069
- /**
2070
- * Get the style (block type qualifier) for this block.
2071
- * @returns the style for this block
2072
- */
2073
- getStyle(): string;
2074
-
2075
- /**
2076
- * Set the style for this block.
2077
- * @param style - Style
2078
- */
2079
- setStyle(style: string): void;
2080
-
2081
- /**
2082
- * Get the location in the AsciiDoc source where this block begins.
2083
- * @returns the location in the AsciiDoc source where this block begins
2084
- */
2085
- getSourceLocation(): Cursor;
2086
-
2087
- /**
2088
- * Get the caption for this block.
2089
- * @returns the caption for this block
2090
- */
2091
- getCaption(): string | undefined;
2092
-
2093
- /**
2094
- * Set the caption for this block.
2095
- * @param caption - Caption
2096
- */
2097
- setCaption(caption: string): void;
2098
-
2099
- /**
2100
- * Get the level of this section or the section level in which this block resides.
2101
- * @returns he level (Integer) of this section
2102
- */
2103
- getLevel(): number;
2104
-
2105
- /**
2106
- * Get the substitution keywords to be applied to the contents of this block.
2107
- *
2108
- * @returns the list of {string} substitution keywords associated with this block.
2109
- */
2110
- getSubstitutions(): string[];
2111
-
2112
- /**
2113
- * Check whether a given substitution keyword is present in the substitutions for this block.
2114
- *
2115
- * @returns whether the substitution is present on this block.
2116
- */
2117
- hasSubstitution(): boolean;
2118
-
2119
- /**
2120
- * Remove the specified substitution keyword from the list of substitutions for this block.
2121
- *
2122
- * @returns undefined
2123
- */
2124
- removeSubstitution(): any;
2125
-
2126
- /**
2127
- * Checks if the {@link AbstractBlock} contains any child blocks.
2128
- * @returns whether the {@link AbstractBlock} has child blocks.
2129
- */
2130
- hasBlocks(): boolean;
2131
-
2132
- /**
2133
- * Get the list of {@link AbstractBlock} sub-blocks for this block.
2134
- * @returns a list of {@link AbstractBlock} sub-blocks
2135
- */
2136
- getBlocks(): any[];
2137
-
2138
- /**
2139
- * Get the converted result of the child blocks by converting the children appropriate to content model that this block supports.
2140
- * @returns the converted result of the child blocks
2141
- */
2142
- getContent(): string|undefined;
2143
-
2144
- /**
2145
- * Get the converted content for this block.
2146
- * If the block has child blocks, the content method should cause them to be converted
2147
- * and returned as content that can be included in the parent block's template.
2148
- * @returns the converted String content for this block
2149
- */
2150
- convert(): string;
2151
-
2152
- /**
2153
- * Query for all descendant block-level nodes in the document tree
2154
- * that match the specified selector (context, style, id, and/or role).
2155
- * If a function block is given, it's used as an additional filter.
2156
- * If no selector or function block is supplied, all block-level nodes in the tree are returned.
2157
- * @example
2158
- * doc.findBy({'context': 'section'});
2159
- * // => { level: 0, title: "Hello, AsciiDoc!", blocks: 0 }
2160
- * // => { level: 1, title: "First Section", blocks: 1 }
2161
- *
2162
- * doc.findBy({'context': 'section'}, function (section) { return section.getLevel() === 1; });
2163
- * // => { level: 1, title: "First Section", blocks: 1 }
2164
- *
2165
- * doc.findBy({'context': 'listing', 'style': 'source'});
2166
- * // => { context: :listing, content_model: :verbatim, style: "source", lines: 1 }
2167
- *
2168
- * @returns a list of block-level nodes that match the filter or an empty list if no matches are found
2169
- */
2170
- findBy(selector: Selector | ((block: AbstractBlock) => boolean | string), block?: ((block: AbstractBlock) => boolean | string)): AbstractBlock[];
2171
-
2172
- /**
2173
- * Get the source line number where this block started.
2174
- * @returns the source line number where this block started
2175
- */
2176
- getLineNumber(): number;
2177
-
2178
- /**
2179
- * Check whether this block has any child Section objects.
2180
- * Only applies to Document and Section instances.
2181
- * @returns true if this block has child Section objects, otherwise false
2182
- */
2183
- hasSections(): boolean;
2184
-
2185
- /**
2186
- * Get the Array of child Section objects.
2187
- * Only applies to Document and Section instances.
2188
- * @returns an {Array} of {@link Section} objects
2189
- */
2190
- getSections(): Section[];
2191
-
2192
- /**
2193
- * Get the numeral of this block (if section, relative to parent, otherwise absolute).
2194
- * Only assigned to section if automatic section numbering is enabled.
2195
- * Only assigned to formal block (block with title) if corresponding caption attribute is present.
2196
- * If the section is an appendix, the numeral is a letter (starting with A).
2197
- * @returns the numeral
2198
- */
2199
- getNumeral(): string;
2200
-
2201
- /**
2202
- * Set the numeral of this block.
2203
- * @param value - The numeral value
2204
- */
2205
- setNumeral(value: string): void;
2206
-
2207
- /**
2208
- * A convenience method that checks whether the title of this block is defined.
2209
- *
2210
- * @returns a {boolean} indicating whether this block has a title.
2211
- */
2212
- hasTitle(): boolean;
2213
-
2214
- /**
2215
- * Returns the converted alt text for this block image.
2216
- *
2217
- * @returns the {string} value of the alt attribute with XML special character and replacement substitutions applied.
2218
- */
2219
- getAlt(): string;
2220
- }
2221
-
2222
- /**
2223
- * @description
2224
- * Methods for managing sections of AsciiDoc content in a document.
2225
- *
2226
- * @example
2227
- * <pre>
2228
- * section = asciidoctor.Section.create()
2229
- * section.setTitle('Section 1')
2230
- * section.setId('sect1')
2231
- * section.getBlocks().length // 0
2232
- * section.getId() // "sect1"
2233
- * section.append(newBlock)
2234
- * section.getBlocks().length // 1
2235
- * </pre>
2236
- */
2237
- export class Section extends AbstractBlock {
2238
- /**
2239
- * Create a {Section} object.
2240
- * @param [parent] - The parent AbstractBlock. If set, must be a Document or Section object (default: undefined)
2241
- * @param [level] - The Integer level of this section (default: 1 more than parent level or 1 if parent not defined)
2242
- * @param [numbered] - A Boolean indicating whether numbering is enabled for this Section (default: false)
2243
- * @param [opts] - An optional JSON of options (default: {})
2244
- *
2245
- * @returns a new {Section} object
2246
- */
2247
- static create(parent?: AbstractBlock, level?: number, numbered?: boolean, opts?: object): Section;
2248
-
2249
- /**
2250
- * Set the level of this section or the section level in which this block resides.
2251
- * @param level - Level (Integer)
2252
- */
2253
- setLevel(level: number): void;
2254
-
2255
- /**
2256
- * Get the 0-based index order of this section within the parent block.
2257
- */
2258
- getIndex(): number;
2259
-
2260
- /**
2261
- * Set the 0-based index order of this section within the parent block.
2262
- * @param index - The index order of this section
2263
- */
2264
- setIndex(index: number): void;
2265
-
2266
- /**
2267
- * Get the section name of this section.
2268
- */
2269
- getSectionName(): string;
2270
-
2271
- /**
2272
- * Set the section name of this section.
2273
- * @param value - The section name
2274
- */
2275
- setSectionName(value: string): void;
2276
-
2277
- /**
2278
- * Get the section number of this section.
2279
- */
2280
- getSectionNumeral(): string;
2281
-
2282
- // alias
2283
- getSectionNumber(): string;
2284
-
2285
- /**
2286
- * Get the flag to indicate whether this is a special section or a child of one.
2287
- */
2288
- isSpecial(): boolean;
2289
-
2290
- /**
2291
- * Set the flag to indicate whether this is a special section or a child of one.
2292
- * @param value - A flag to indicated if this is a special section
2293
- */
2294
- setSpecial(value: boolean): void;
2295
-
2296
- /**
2297
- * Get the state of the numbered attribute at this section (need to preserve for creating TOC).
2298
- */
2299
- isNumbered(): boolean;
2300
-
2301
- /**
2302
- * Get the caption for this section (only relevant for appendices).
2303
- */
2304
- getCaption(): string | undefined;
2305
-
2306
- /**
2307
- * Get the name of the Section (title)
2308
- * @see {@link AbstractBlock#getTitle}
2309
- */
2310
- getName(): string;
2311
- }
2312
-
2313
- /**
2314
- * Methods for managing inline elements in AsciiDoc block.
2315
- */
2316
- export class Inline extends AbstractNode {
2317
- /**
2318
- * Create a new Inline element.
2319
- * @returns a new Inline element
2320
- */
2321
- static create(parent: AbstractBlock, context: string, text?: string, opts?: Record<string, unknown>): Inline;
2322
-
2323
- /**
2324
- * Get the converted content for this inline node.
2325
- * @returns the converted String content for this inline node
2326
- */
2327
- convert(): string;
2328
-
2329
- /**
2330
- * Get the converted String text of this Inline node, if applicable.
2331
- * @returns the converted String text for this Inline node, or undefined if not applicable for this node.
2332
- */
2333
- getText(): string;
2334
-
2335
- /**
2336
- * Get the String sub-type (aka qualifier) of this Inline node.
2337
- *
2338
- * This value is used to distinguish different variations of the same node
2339
- * category, such as different types of anchors.
2340
- *
2341
- * @returns the string sub-type of this Inline node.
2342
- */
2343
- getType(): string;
2344
-
2345
- /**
2346
- * Get the primary String target of this Inline node.
2347
- *
2348
- * @returns the string target of this Inline node.
2349
- */
2350
- getTarget(): string | undefined;
2351
-
2352
- /**
2353
- * Returns the converted alt text for this inline image.
2354
- *
2355
- * @returns the {string} value of the alt attribute.
2356
- */
2357
- getAlt(): string;
2358
- }
2359
-
2360
- /**
2361
- * Methods for managing AsciiDoc content blocks.
2362
- *
2363
- * @example
2364
- * block = Asciidoctor::Block.new(parent, :paragraph, source: '_This_ is a <test>')
2365
- * block.content
2366
- * => "<em>This</em> is a &lt;test&gt;"
2367
- */
2368
- export class Block extends AbstractBlock {
2369
- /**
2370
- * Create a {Block} object.
2371
- * @param parent - The parent {AbstractBlock} with a compound content model to which this {Block} will be appended.
2372
- * @param context - The context name for the type of content (e.g., "paragraph").
2373
- * @param [opts] - a JSON of options to customize block initialization: (default: {})
2374
- * @param opts.content_model - indicates whether blocks can be nested in this {Block} ("compound"),
2375
- * otherwise how the lines should be processed ("simple", "verbatim", "raw", "empty"). (default: "simple")
2376
- * @param opts.attributes - a JSON of attributes (key/value pairs) to assign to this {Block}. (default: {})
2377
- * @param opts.source - a String or {Array} of raw source for this {Block}. (default: undefined)
2378
- *
2379
- * IMPORTANT: If you don't specify the `subs` option, you must explicitly call the `commit_subs` method to resolve and assign the substitutions
2380
- * to this block (which are resolved from the `subs` attribute, if specified, or the default substitutions based on this block's context).
2381
- * If you want to use the default subs for a block, pass the option `subs: "default"`.
2382
- * You can override the default subs using the `default_subs` option.
2383
- *
2384
- * @returns a new {Block} object
2385
- */
2386
- static create(parent: AbstractBlock, context: string, opts?: object): Block;
2387
-
2388
- /**
2389
- * Get the source of this block.
2390
- * @returns the String source of this block.
2391
- */
2392
- getSource(): string;
2393
-
2394
- /**
2395
- * Get the source lines of this block.
2396
- * @returns the String {Array} of source lines for this block.
2397
- */
2398
- getSourceLines(): string[];
2399
- }
2400
-
2401
- /** Methods for managing AsciiDoc tables. */
2402
- export class Table extends AbstractBlock {
2403
- /**
2404
- * Create a new Table element.
2405
- * @param parent - The parent {AbstractBlock}.
2406
- * @param attributes - a JSON of attributes
2407
- * @returns a new {Table} object
2408
- */
2409
- static create(parent: AbstractBlock, attributes: Attributes): Table;
2410
-
2411
- /**
2412
- * Get the caption of the table.
2413
- * @returns the String caption
2414
- */
2415
- getCaption(): string;
2416
-
2417
- /**
2418
- * Get the rows of this table.
2419
- * @returns an {Table.Rows} object with the members "head", "body" and "foot"
2420
- */
2421
- getRows(): Table.Rows;
2422
-
2423
- /**
2424
- * Get the columns of this table.
2425
- * @returns an {Array} of {Table.Column}
2426
- */
2427
- getColumns(): Table.Column[];
2428
-
2429
- /**
2430
- * Get the head rows of this table.
2431
- * @returns an {Array} of {Array} of {Table.Cell}.
2432
- */
2433
- getHeadRows(): Table.Cell[][];
2434
-
2435
- /**
2436
- * Check if the table has a head rows.
2437
- * @returns true if the table has head rows, false otherwise.
2438
- */
2439
- hasHeadRows(): boolean;
2440
-
2441
- /**
2442
- * Get the body rows of this table.
2443
- * @returns an {Array} of {Array} of {Table.Cell}.
2444
- */
2445
- getBodyRows(): Table.Cell[][];
2446
-
2447
- /**
2448
- * Check if the table has a body rows.
2449
- * @returns true if the table has body rows, false otherwise.
2450
- */
2451
- hasBodyRows(): boolean;
2452
-
2453
- /**
2454
- * Get the foot rows of this table.
2455
- * @returns an {Array} of {Array} of {Table.Cell}.
2456
- */
2457
- getFootRows(): Table.Cell[][];
2458
-
2459
- /**
2460
- * Check if the table has a foot rows.
2461
- * @returns true if the table has foot rows, false otherwise.
2462
- */
2463
- hasFootRows(): boolean;
2464
-
2465
- /**
2466
- * Check if the table has a header option set.
2467
- * @returns true if the header option is set, false otherwise.
2468
- */
2469
- hasHeaderOption(): boolean;
2470
-
2471
- /**
2472
- * Check if the table has the footer option set.
2473
- * @returns true if the footer option is set, false otherwise.
2474
- */
2475
- hasFooterOption(): boolean;
2476
-
2477
- /**
2478
- * Check if the table has the autowidth option set.
2479
- * @returns true if the autowidth option is set, false otherwise.
2480
- */
2481
- hasAutowidthOption(): boolean;
2482
-
2483
- /**
2484
- * Get the number of rows in the table.
2485
- * Please note that the header and footer rows are also counted.
2486
- * @returns the number of rows in the table.
2487
- */
2488
- getRowCount(): number;
2489
-
2490
- /**
2491
- * Set the number of rows in the table.
2492
- * Please note that the header and footer rows are also counted.
2493
- * @param value - the value
2494
- */
2495
- setRowCount(value: number): void;
2496
-
2497
- /**
2498
- * Get the number of columns in the table.
2499
- * @returns the number of columns in the table.
2500
- */
2501
- getColumnCount(): number;
2502
-
2503
- /**
2504
- * Set the number of columns in the table.
2505
- * @param value - the value
2506
- */
2507
- setColumnCount(value: number): void;
2508
- }
2509
-
2510
- /**
2511
- * Methods for managing AsciiDoc tables.
2512
- */
2513
- export namespace Table {
2514
- class Rows {
2515
- /**
2516
- * head rows.
2517
- */
2518
- head: Cell[][];
2519
- /**
2520
- * body rows.
2521
- */
2522
- body: Cell[][];
2523
- /**
2524
- * foot rows.
2525
- */
2526
- foot: Cell[][];
2527
-
2528
- /**
2529
- * Create a new {Rows} object.
2530
- * @param head - head rows
2531
- * @param foot - foot rows
2532
- * @param body - body rows
2533
- * @returns a new {Rows} object.
2534
- */
2535
- static create(head: Cell[][], foot: Cell[][], body: Cell[][]): Rows;
2536
-
2537
- /**
2538
- * Get head rows.
2539
- * @returns head rows.
2540
- */
2541
- getHead(): Cell[][];
2542
-
2543
- /**
2544
- * Get body rows.
2545
- * @returns body rows.
2546
- */
2547
- getBody(): Cell[][];
2548
-
2549
- /**
2550
- * Get foot rows.
2551
- * @returns foot rows.
2552
- */
2553
- getFoot(): Cell[][];
2554
-
2555
- /**
2556
- * Retrieve the rows grouped by section as a nested {Array}.
2557
- * Creates a 2-dimensional array of two element entries.
2558
- * The first element is the section name as a String.
2559
- * The second element is the Array of rows in that section.
2560
- * The entries are in document order (head, foot, body).
2561
- * @returns a 2-dimensional {Array} two element entries
2562
- */
2563
- bySection(): Array<[string, Cell[][]]>;
2564
- }
2565
-
2566
- /**
2567
- * Methods to manage the columns of an AsciiDoc table.
2568
- * In particular, it keeps track of the column specs.
2569
- */
2570
- class Column {
2571
- static create(table: Table, index: number, attributes: Attributes): Column;
2572
-
2573
- /**
2574
- * Get the column number of this cell.
2575
- * @returns the column number.
2576
- */
2577
- getColumnNumber(): number;
2578
-
2579
- /**
2580
- * Get the width of this cell.
2581
- * @returns the width of this cell.
2582
- */
2583
- getWidth(): string | undefined;
2584
-
2585
- /**
2586
- * Get the horizontal align of this cell.
2587
- * @returns the horizontal align of this cell.
2588
- */
2589
- getHorizontalAlign(): string | undefined;
2590
-
2591
- /**
2592
- * Get the vertical align of this cell.
2593
- * @returns the vertical align of this cell.
2594
- */
2595
- getVerticalAlign(): string | undefined;
2596
-
2597
- /**
2598
- * Get the style of this cell.
2599
- * @returns the style of this cell.
2600
- */
2601
- getStyle(): string | undefined;
2602
- }
2603
-
2604
- /**
2605
- * Methods for managing the cells in an AsciiDoc table.
2606
- */
2607
- class Cell {
2608
- /**
2609
- * Get the column span of this {@link Cell} node.
2610
- * @returns a {number} of the number of columns this cell will span (default: undefined).
2611
- */
2612
- getColumnSpan(): number | undefined;
2613
-
2614
- /**
2615
- * Set the column span of this {@link Cell} node.
2616
- * @param value - the value
2617
- * @returns the new colspan value.
2618
- */
2619
- setColumnSpan(value: number): number;
2620
-
2621
- /**
2622
- * Get the row span of this {@link Cell} node
2623
- * @returns a {number} of the number of rows this cell will span (default: undefined).
2624
- */
2625
- getRowSpan(): number | undefined;
2626
-
2627
- /**
2628
- * Set the row span of this {@link Cell} node
2629
- * @param value - the value
2630
- * @returns the new rowspan value.
2631
- */
2632
- setRowSpan(value: number): number;
2633
-
2634
- /**
2635
- * Get the content of the cell.
2636
- * This method should not be used for cells in the head row or that have the literal style.
2637
- * @returns the String content of the cell.
2638
- */
2639
- getContent(): string;
2640
-
2641
- /**
2642
- * Get the text of the cell.
2643
- * @returns the text of the cell.
2644
- */
2645
- getText(): string;
2646
-
2647
- /**
2648
- * Get the source of the cell.
2649
- * @returns the source of the cell.
2650
- */
2651
- getSource(): string;
2652
-
2653
- /**
2654
- * Get the lines of the cell.
2655
- * @returns the lines of the cell.
2656
- */
2657
- getLines(): string[];
2658
-
2659
- /**
2660
- * Get the line number of the cell.
2661
- * @returns the line number of the cell.
2662
- */
2663
- getLineNumber(): number | undefined;
2664
-
2665
- /**
2666
- * Get the source file of the cell.
2667
- * @returns the file of the cell.
2668
- */
2669
- getFile(): string | undefined;
2670
-
2671
- /**
2672
- * Get the style of the cell.
2673
- * @returns the style of the cell.
2674
- */
2675
- getStyle(): string | undefined;
2676
-
2677
- /**
2678
- * Get the column of this cell.
2679
- * @returns the column of this cell.
2680
- */
2681
- getColumn(): Column | undefined;
2682
-
2683
- /**
2684
- * Get the width of this cell.
2685
- * @returns the width of this cell.
2686
- */
2687
- getWidth(): string | undefined;
2688
-
2689
- /**
2690
- * Get the column width in percentage of this cell.
2691
- * @returns the column width in percentage of this cell.
2692
- */
2693
- getColumnPercentageWidth(): string | undefined;
2694
-
2695
- /**
2696
- * Get the nested {Document} of this cell when style is 'asciidoc'.
2697
- * @returns the nested {Document}
2698
- */
2699
- getInnerDocument(): Document | undefined;
2700
- }
2701
- }
2702
-
2703
- /**
2704
- * @description
2705
- * An abstract base class that provides state and methods for managing a node of AsciiDoc content.
2706
- * The state and methods on this class are common to all content segments in an AsciiDoc document.
2707
- */
2708
- export class AbstractNode implements Logging {
2709
- /**
2710
- * Resolve the list of comma-delimited subs against the possible options.
2711
- *
2712
- * @param subs - The comma-delimited String of substitution names or aliases.
2713
- * @param [type] - A String representing the context for which the subs are being resolved (default: 'block').
2714
- * @param [defaults] - An Array of substitutions to start with when computing incremental substitutions (default: undefined).
2715
- * @param [subject] - The String to use in log messages to communicate the subject for which subs are being resolved (default: undefined)
2716
- *
2717
- * @returns An Array of Strings representing the substitution operation or nothing if no subs are found.
2718
- */
2719
-
2720
- node_name: string;
2721
- context: string
2722
-
2723
- resolveSubstitutions(subs: string, type?: string, defaults?: string[], subject?: string): string[] | undefined;
2724
-
2725
- /**
2726
- * Call {@link AbstractNode#resolveSubstitutions} for the 'block' type.
2727
- *
2728
- * @see {@link AbstractNode#resolveSubstitutions}
2729
- */
2730
- resolveBlockSubstitutions(subs: string, defaults?: string[], subject?: string): string[] | undefined;
2731
-
2732
- /**
2733
- * Call {@link AbstractNode#resolveSubstitutions} for the 'inline' type with the subject set as passthrough macro.
2734
- *
2735
- * @see {@link AbstractNode#resolveSubstitutions}
2736
- */
2737
- resolvePassSubstitutions(subs: string): string[] | undefined;
2738
-
2739
- /**
2740
- * Apply the specified substitutions to the text.
2741
- *
2742
- * @param text - The String or String Array of text to process; must not be undefined.
2743
- * @param [subs] - The substitutions to perform; must be a String, an Array or undefined (default: NORMAL_SUBS).
2744
- *
2745
- * @returns a String or String Array to match the type of the text argument with substitutions applied.
2746
- */
2747
- applySubstitutions(text: string, subs?: string | string[]): string | string[];
2748
-
2749
- /**
2750
- * @returns the String name of this node
2751
- */
2752
- getNodeName(): string;
2753
-
2754
- /**
2755
- * @returns the JSON of attributes for this node
2756
- */
2757
- getAttributes(): any;
2758
-
2759
- /**
2760
- * Get the value of the specified attribute.
2761
- * If the attribute is not found on this node, fallback_name is set, and this node is not the Document node, get the value of the specified attribute from the Document node.
2762
- *
2763
- * Look for the specified attribute in the attributes on this node and return the value of the attribute, if found.
2764
- * Otherwise, if fallback_name is set (default: same as name) and this node is not the Document node, look for that attribute on the Document node and return its value, if found.
2765
- * Otherwise, return the default value (default: undefined).
2766
- *
2767
- * @param name - The String of the attribute to resolve.
2768
- * @param [defaultValue] - The {Object} value to return if the attribute is not found (default: undefined).
2769
- * @param [fallbackName] - The String of the attribute to resolve on the Document if the attribute is not found on this node (default: same as name).
2770
- *
2771
- * @returns the {Object} value (typically a String) of the attribute or defaultValue if the attribute is not found.
2772
- */
2773
- getAttribute(name: string, defaultValue?: any, fallbackName?: string): any;
2774
-
2775
- /**
2776
- * Check whether the specified attribute is present on this node.
2777
- *
2778
- * @param name - The String of the attribute to resolve.
2779
- * @returns true if the attribute is present, otherwise false
2780
- */
2781
- hasAttribute(name: string): boolean;
2782
-
2783
- /**
2784
- * Check if the specified attribute is defined using the same logic as {AbstractNode#getAttribute}, optionally performing acomparison with the expected value if specified.
2785
- *
2786
- * Look for the specified attribute in the attributes on this node.
2787
- * If not found, fallback_name is specified (default: same as name), and this node is not the Document node, look for that attribute on the Document node.
2788
- * In either case, if the attribute is found, and the comparison value is truthy, return whether the two values match.
2789
- * Otherwise, return whether the attribute was found.
2790
- *
2791
- * @param name - The String name of the attribute to resolve.
2792
- * @param [expectedValue] - The expected Object value of the attribute (default: undefined).
2793
- * @param fallbackName - The String of the attribute to resolve on the Document if the attribute is not found on this node (default: same as name).
2794
- *
2795
- * @returns a Boolean indicating whether the attribute exists and, if a truthy comparison value is specified, whether the value of the attribute matches the comparison value.
2796
- */
2797
- isAttribute(name: string, expectedValue?: any, fallbackName?: string): boolean;
2798
-
2799
- /**
2800
- * Assign the value to the attribute name for the current node.
2801
- *
2802
- * @param name - The String attribute name to assign
2803
- * @param value - The Object value to assign to the attribute (default: '')
2804
- * @param overwrite - A Boolean indicating whether to assign the attribute if currently present in the attributes JSON (default: true)
2805
- *
2806
- * @returns a Boolean indicating whether the assignment was performed
2807
- */
2808
- setAttribute(name: string, value: any, overwrite?: boolean): boolean;
2809
-
2810
- /**
2811
- * Remove the attribute from the current node.
2812
- * @param name - The String attribute name to remove
2813
- * @returns the previous {string} value, or undefined if the attribute was not present.
2814
- */
2815
- removeAttribute(name: string): string | undefined;
2816
-
2817
- /**
2818
- * Get the {@link Document} to which this node belongs.
2819
- *
2820
- * @returns the {@link Document} object to which this node belongs.
2821
- */
2822
- getDocument(): Document;
2823
-
2824
- /**
2825
- * Get the {@link AbstractNode} to which this node is attached.
2826
- *
2827
- * @returns the {@link AbstractNode} object to which this node is attached,
2828
- * or undefined if this node has no parent.
2829
- */
2830
- getParent(): AbstractNode | undefined;
2831
-
2832
- /**
2833
- * @returns true if this {AbstractNode} is an instance of {Inline}
2834
- */
2835
- isInline(): boolean;
2836
-
2837
- /**
2838
- * @returns true if this {AbstractNode} is an instance of {Block}
2839
- */
2840
- isBlock(): boolean;
2841
-
2842
- /**
2843
- * Checks if the role attribute is set on this node and, if an expected value is given, whether the space-separated role matches that value.
2844
- *
2845
- * @param expectedValue - The expected String value of the role (optional, default: undefined)
2846
- *
2847
- * @returns a Boolean indicating whether the role attribute is set on this node and, if an expected value is given, whether the space-separated role matches that value.
2848
- */
2849
- isRole(expectedValue?: string): boolean;
2850
-
2851
- /**
2852
- * Retrieves the space-separated String role for this node.
2853
- *
2854
- * @returns the role as a space-separated String.
2855
- */
2856
- getRole(): string | undefined;
2857
-
2858
- /**
2859
- * Sets the value of the role attribute on this node.
2860
- *
2861
- * @param names - A single role name, a space-separated String of role names or a list of role names
2862
- *
2863
- * @returns the value of the role attribute.
2864
- */
2865
- setRole(...names: string[]): string;
2866
-
2867
- /**
2868
- * Sets the value of the role attribute on this node.
2869
- *
2870
- * @param names - an Array of role names
2871
- *
2872
- * @returns the value of the role attribute.
2873
- */
2874
- setRole(names: string[]): string;
2875
-
2876
- /**
2877
- * Checks if the specified role is present in the list of roles for this node.
2878
- *
2879
- * @param name - The String name of the role to find.
2880
- *
2881
- * @returns a Boolean indicating whether this node has the specified role.
2882
- */
2883
- hasRole(name: string): boolean;
2884
-
2885
- /**
2886
- * Retrieves the String role names for this node as an Array.
2887
- *
2888
- * @returns the role names as a String {Array}, which is empty if the role attribute is absent on this node.
2889
- */
2890
- getRoles(): string[];
2891
-
2892
- /**
2893
- * Adds the given role directly to this node.
2894
- *
2895
- * @param name - The name of the role to add
2896
- *
2897
- * @returns a Boolean indicating whether the role was added.
2898
- */
2899
- addRole(name: string): boolean;
2900
-
2901
- /**
2902
- * Public: Removes the given role directly from this node.
2903
- *
2904
- * @param name - The name of the role to remove
2905
- *
2906
- * @returns a Boolean indicating whether the role was removed.
2907
- */
2908
- removeRole(name: string): boolean;
2909
-
2910
- /**
2911
- * A convenience method that checks if the reftext attribute is defined.
2912
- * @returns A Boolean indicating whether the reftext attribute is defined
2913
- */
2914
- isReftext(): boolean;
2915
-
2916
- /**
2917
- * A convenience method that returns the value of the reftext attribute with substitutions applied.
2918
- * @returns the value of the reftext attribute with substitutions applied.
2919
- */
2920
- getReftext(): string | undefined;
2921
-
2922
- /**
2923
- * @returns the context name for this node
2924
- */
2925
- getContext(): string;
2926
-
2927
- /**
2928
- * @returns the String id of this node
2929
- */
2930
- getId(): string;
2931
-
2932
- /**
2933
- * @param id - the String id of this node
2934
- */
2935
- setId(id: string): void;
2936
-
2937
- /**
2938
- * A convenience method to check if the specified option attribute is enabled on the current node.
2939
- * Check if the option is enabled. This method simply checks to see if the <name>-option attribute is defined on the current node.
2940
- *
2941
- * @param name - the String name of the option
2942
- *
2943
- * @return a Boolean indicating whether the option has been specified
2944
- */
2945
- isOption(name: string): boolean;
2946
-
2947
- /**
2948
- * Set the specified option on this node.
2949
- * This method sets the specified option on this node by setting the <name>-option attribute.
2950
- *
2951
- * @param name - the String name of the option
2952
- */
2953
- setOption(name: string): void;
2954
-
2955
- /**
2956
- * Construct a reference or data URI to an icon image for the specified icon name.
2957
- *
2958
- * If the 'icon' attribute is set on this block, the name is ignored and the value of this attribute is used as the target image path.
2959
- * Otherwise, construct a target image path by concatenating the value of the 'iconsdir' attribute,
2960
- * the icon name, and the value of the 'icontype' attribute (defaulting to 'png').
2961
- *
2962
- * The target image path is then passed through the {@link AbstractNode#getImageUri} method.
2963
- * If the 'data-uri' attribute is set on the document, the image will be safely converted to a data URI.
2964
- *
2965
- * The return value of this method can be safely used in an image tag.
2966
- *
2967
- * @param name - the String name of the icon
2968
- *
2969
- * @returns A String reference or data URI for an icon image
2970
- */
2971
- getIconUri(name: string): string;
2972
-
2973
- /**
2974
- * Construct a URI reference to the target media.
2975
- *
2976
- * If the target media is a URI reference, then leave it untouched.
2977
- *
2978
- * The target media is resolved relative to the directory retrieved from the specified attribute key, if provided.
2979
- *
2980
- * The return value can be safely used in a media tag (img, audio, video).
2981
- *
2982
- * @param target - A String reference to the target media
2983
- * @param assetDirKey - The String attribute key used to lookup the directory where the media is located (default: 'imagesdir')
2984
- *
2985
- * @returns A String reference for the target media
2986
- */
2987
- getMediaUri(target: string, assetDirKey?: string): string;
2988
-
2989
- /**
2990
- * Construct a URI reference or data URI to the target image.
2991
- *
2992
- * If the target image is a URI reference, then leave it untouched.
2993
- *
2994
- * The target image is resolved relative to the directory retrieved from the specified attribute key, if provided.
2995
- *
2996
- * If the 'data-uri' attribute is set on the document, and the safe mode level is less than SafeMode.SECURE,
2997
- * the image will be safely converted to a data URI by reading it from the same directory.
2998
- * If neither of these conditions are satisfied, a relative path (i.e., URL) will be returned.
2999
- *
3000
- * The return value of this method can be safely used in an image tag.
3001
- *
3002
- * @param targetImage - A String path to the target image
3003
- * @param assetDirKey - The String attribute key used to lookup the directory where the image is located (default: 'imagesdir')
3004
- *
3005
- * @returns A String reference or data URI for the target image
3006
- */
3007
- getImageUri(targetImage: string, assetDirKey?: string): string;
3008
-
3009
- /**
3010
- * Get the {Converter} instance being used to convert the current {Document}.
3011
- */
3012
- getConverter(): object;
3013
-
3014
- /**
3015
- */
3016
- readContents(): void;
3017
-
3018
- /**
3019
- * Read the contents of the file at the specified path.
3020
- * This method assumes that the path is safe to read.
3021
- * It checks that the file is readable before attempting to read it
3022
- * @param path - the {string} path from which to read the contents
3023
- * @param options - a JSON of options to control processing (default: {})
3024
- * - warn_on_failure a {boolean} that controls whether a warning is issued if the file cannot be read (default: false)
3025
- * - normalize a {boolean} that controls whether the lines are normalized and coerced to UTF-8 (default: false)
3026
- * @returns the {string} content of the file at the specified path, or undefined if the file does not exist.
3027
- */
3028
- readAsset(path: string, options: any): string;
3029
-
3030
- /**
3031
- */
3032
- normalizeWebPath(): void;
3033
-
3034
- /**
3035
- */
3036
- normalizeSystemPath(): void;
3037
-
3038
- /**
3039
- */
3040
- normalizeAssetPath(): void;
3041
-
3042
- // alias
3043
- getLogger(): Logger;
3044
-
3045
- createLogMessage(text: string, context: any): LoggerMessage;
3046
- }
3047
-
3048
- /**
3049
- * Methods for managing AsciiDoc lists (ordered, unordered and description lists).
3050
- */
3051
- export class List extends AbstractBlock {
3052
- /**
3053
- * Checks if the {@link List} contains any child {@link ListItem}.
3054
- * @returns whether the {@link List} has child {@link ListItem}.
3055
- */
3056
- hasItems(): boolean;
3057
-
3058
- /**
3059
- * Get the Array of {@link ListItem} nodes for this {@link List}.
3060
- * @returns an Array of {@link ListItem} nodes.
3061
- */
3062
- getItems(): ListItem[];
3063
- }
3064
-
3065
- /**
3066
- * Methods for managing items for AsciiDoc olists, ulist, and dlists.
3067
- *
3068
- * In a description list (dlist), each item is a tuple that consists of a 2-item Array of ListItem terms and a ListItem description (i.e., [[term, term, ...], desc].
3069
- * If a description is not set, then the second entry in the tuple is nil.
3070
- */
3071
- export class ListItem extends AbstractBlock {
3072
- /**
3073
- * Get the converted String text of this {@link ListItem} node.
3074
- * @returns the converted String text for this {@link ListItem} node.
3075
- */
3076
- getText(): string;
3077
-
3078
- /**
3079
- * Set the String source text of this {@link ListItem} node.
3080
- * @returns the new String text assigned to this {@link ListItem}
3081
- */
3082
- setText(text: string): string;
3083
-
3084
- /**
3085
- * A convenience method that checks whether the text of this {@link ListItem} is not blank (i.e. not undefined or empty string).
3086
- * @returns whether the text is not blank
3087
- */
3088
- hasText(): boolean;
3089
-
3090
- /**
3091
- * Get the {string} used to mark this {@link ListItem}.
3092
- */
3093
- getMarker(): string;
3094
-
3095
- /**
3096
- * Set the {string} used to mark this {@link ListItem}.
3097
- *
3098
- * @param marker - the {string} used to mark this {@link ListItem}
3099
- */
3100
- setMarker(marker: string): void;
3101
-
3102
- /**
3103
- * Get the {@link List} to which this {@link ListItem} is attached.
3104
- *
3105
- * @returns the {@link List} object to which this {@link ListItem} is attached,
3106
- * or undefined if this node has no parent.
3107
- */
3108
- getList(): List;
3109
-
3110
- /**
3111
- * @see {@link ListItem#getList}
3112
- */
3113
- getParent(): List;
3114
- }
3115
-
3116
- export namespace Html5Converter {
3117
- /**
3118
- * Create a new {@link Html5Converter}.
3119
- * @returns a {@link Html5Converter}
3120
- */
3121
- function create(): Html5Converter;
3122
- }
3123
-
3124
- interface AbstractConverter {
3125
- /**
3126
- * Converts an {AbstractNode} using the given transform.
3127
- * This method must be implemented by a concrete converter class.
3128
- *
3129
- * @param node - The concrete instance of AbstractNode to convert.
3130
- * @param [transform] - An optional String transform that hints at which transformation should be applied to this node.
3131
- * If a transform is not given, the transform is often derived from the value of the {AbstractNode#getNodeName} property. (optional, default: undefined)
3132
- * @param [opts]- An optional JSON of options hints about how to convert the node. (optional, default: undefined)
3133
- *
3134
- * @returns the {String} result.
3135
- */
3136
- convert(node: AbstractNode, transform?: string, opts?: unknown): string;
3137
- }
3138
-
3139
- interface ConverterConstructor {
3140
- new(backend?: string, opts?: unknown): AbstractConverter;
3141
- }
3142
-
3143
- export class Converter implements AbstractConverter {
3144
- /**
3145
- * Converts an {AbstractNode} using the given transform.
3146
- * This method must be implemented by a concrete converter class.
3147
- *
3148
- * @param node - The concrete instance of AbstractNode to convert.
3149
- * @param [transform] - An optional String transform that hints at which transformation should be applied to this node.
3150
- * If a transform is not given, the transform is often derived from the value of the {AbstractNode#getNodeName} property. (optional, default: undefined)
3151
- * @param [opts]- An optional JSON of options hints about how to convert the node. (optional, default: undefined)
3152
- *
3153
- * @returns the {String} result.
3154
- */
3155
- convert(node: AbstractNode, transform?: string, opts?: any): string;
3156
- }
3157
-
3158
- /**
3159
- * A built-in {Converter} implementation that generates HTML 5 output.
3160
- */
3161
- export class Html5Converter extends Converter {
3162
- }
3163
-
3164
- export namespace ConverterFactory {
3165
- /**
3166
- * Create an instance of the converter bound to the specified backend.
3167
- *
3168
- * @param backend - look for a converter bound to this keyword.
3169
- * @param opts - a JSON of options to pass to the converter (default: {})
3170
- * @returns a {Converter} instance for converting nodes in an Asciidoctor AST.
3171
- */
3172
- function create(backend: string, opts?: unknown): Converter;
3173
- }
3174
-
3175
- /**
3176
- * A registry of {Converter} instances or classes keyed by backend name.
3177
- */
3178
- interface ConverterRegistry {
3179
- [key: string]: typeof Converter | Converter;
3180
- }
3181
-
3182
- export class ConverterFactory {
3183
- /**
3184
- * Register a custom converter in the global converter factory to handle conversion to the specified backends.
3185
- * If the backend value is an asterisk, the converter is used to handle any backend that does not have an explicit converter.
3186
- *
3187
- * @param converter - The {Converter} instance to register
3188
- * @param backends- A {string} {Array} of backend names that this converter should be registered to handle (optional, default: ['*'])
3189
- */
3190
- register(converter: AbstractConverter | ConverterConstructor, backends?: string[]): void;
3191
-
3192
- /**
3193
- * Retrieves the singleton instance of the converter factory.
3194
- *
3195
- * @param initialize - instantiate the singleton if it has not yet been instantiated.
3196
- * If this value is false and the singleton has not yet been instantiated, this method returns a fresh instance.
3197
- * @returns an instance of the {ConverterFactory}.
3198
- */
3199
- getDefault(initialize: boolean): ConverterFactory;
3200
-
3201
- /**
3202
- * Get the converter registry.
3203
- * @returns the registry
3204
- */
3205
- getRegistry(): ConverterRegistry;
3206
-
3207
- /**
3208
- * Lookup the custom converter registered with this factory to handle the specified backend.
3209
- * @param backend - The {string} backend name.
3210
- * @returns the {Converter} class or instance registered to convert the specified backend or undefined if no match is found.
3211
- */
3212
- for(backend: string): typeof Converter | Converter | undefined;
3213
- }
3214
-
3215
- interface SyntaxHighlighterHighlightOptions {
3216
- [key: string]: any;
3217
-
3218
- /**
3219
- * An Object of callouts extracted from the source, indexed by line number (1-based) (optional).
3220
- */
3221
- callouts?: any;
3222
- /**
3223
- * The String CSS mode ("class" or "inline").
3224
- */
3225
- css_mode?: string;
3226
- /**
3227
- * A 1-based Array of Integer line numbers to highlight (aka emphasize) (optional).
3228
- */
3229
- highlight_lines?: number[];
3230
- /**
3231
- * A String indicating whether lines should be numbered ("table" or "inline") (optional).
3232
- */
3233
- number_lines?: string;
3234
- /**
3235
- * The starting Integer (1-based) line number (optional, default: 1).
3236
- */
3237
- start_line_number?: number;
3238
- /**
3239
- * The String style (aka theme) to use for colorizing the code (optional).
3240
- */
3241
- style?: string;
3242
- }
3243
-
3244
- interface SyntaxHighlighterDocinfoOptions {
3245
- [key: string]: any;
3246
-
3247
- /**
3248
- * A Boolean indicating whether the stylesheet should be linked instead of embedded (optional).
3249
- */
3250
- linkcss?: boolean;
3251
- /**
3252
- * The String base URL for assets loaded from the CDN.
3253
- */
3254
- cdn_base_url?: string;
3255
- /**
3256
- * The String '/' if the converter calling this method emits self-closing tags.
3257
- */
3258
- self_closing_tag_slash?: string;
3259
- }
3260
-
3261
- interface SyntaxHighlighterFormatOptions {
3262
- [key: string]: any;
3263
-
3264
- /**
3265
- * A Boolean that indicates whether wrapping should be disabled (optional).
3266
- */
3267
- nowrap?: boolean;
3268
- }
3269
-
3270
- /**
3271
- * Syntax highlighter functions
3272
- */
3273
- interface SyntaxHighlighterFunctions {
3274
- postConstruct?: (this: SyntaxHighlighter) => any;
3275
- initialize?: (this: SyntaxHighlighter, name: string, backend: string, opts: any) => void;
3276
- format?: (this: SyntaxHighlighter, parent: Document, target: string, attributes?: any) => string;
3277
- highlight?: (this: SyntaxHighlighter, node: Block, source: string, lang: string, opts: SyntaxHighlighterHighlightOptions) => any;
3278
- handlesHighlighting?: (this: SyntaxHighlighter) => boolean;
3279
- hasDocinfo?: (this: SyntaxHighlighter, location: string) => boolean;
3280
- docinfo?: (this: SyntaxHighlighter, location: string, doc: Document, opts: SyntaxHighlighterDocinfoOptions) => string;
3281
- }
3282
-
3283
- /**
3284
- * @description
3285
- * This API is experimental and subject to change.
3286
- *
3287
- * A pluggable adapter for integrating a syntax (aka code) highlighter into AsciiDoc processing.
3288
- *
3289
- * There are two types of syntax highlighter adapters. The first performs syntax highlighting during the convert phase.
3290
- * This adapter type must define a "handlesHighlighting" method that returns true.
3291
- * The companion "highlight" method will then be called to handle the "specialcharacters" substitution for source blocks.
3292
- *
3293
- * The second assumes syntax highlighting is performed on the client (e.g., when the HTML document is loaded).
3294
- * This adapter type must define a "hasDocinfo" method that returns true.
3295
- * The companion "docinfo" method will then be called to insert markup into the output document.
3296
- * The docinfo functionality is available to both adapter types.
3297
- *
3298
- * js provides several a built-in adapter for highlight.js.
3299
- * Additional adapters can be registered using SyntaxHighlighter.register.
3300
- */
3301
- export namespace SyntaxHighlighter {
3302
- /**
3303
- * Associates the syntax highlighter class or object with the specified names.
3304
- *
3305
- * @description This API is experimental and subject to change.
3306
- *
3307
- * @param names - A {string} name or an {Array} of {string} names
3308
- * @param functions - A list of functions representing a {SyntaxHighlighter} or a {SyntaxHighlighter} class to instantiate
3309
- */
3310
- function register(names: string | string[], functions: SyntaxHighlighterFunctions | object): void;
3311
-
3312
- // SyntaxHighlighter.for can be defined because "for" is a reserved keyword :|
3313
-
3314
- /**
3315
- * Retrieves the syntax highlighter class or object registered for the specified name.
3316
- *
3317
- * @description This API is experimental and subject to change.
3318
- *
3319
- * @param name - The {string} name of the syntax highlighter to retrieve.
3320
- * @returns the {SyntaxHighlighter} registered for this name.
3321
- */
3322
- function get(name: string): SyntaxHighlighter | undefined;
3323
- }
3324
-
3325
- export class SyntaxHighlighter {
3326
- $$name: string;
3327
-
3328
- [key: string]: any;
3329
-
3330
- super: (...params: any[]) => void;
3331
-
3332
- /**
3333
- * Format the highlighted source for inclusion in an HTML document.
3334
- *
3335
- * @param node - The source Block being processed.
3336
- * @param lang - The source language String for this Block (e.g., ruby).
3337
- * @param opts - An object of options that control syntax highlighting.
3338
- *
3339
- * @returns the highlighted source String wrapped in preformatted tags (e.g., pre and code)
3340
- */
3341
- format(node: Block, lang: string, opts?: SyntaxHighlighterFormatOptions): string;
3342
-
3343
- /**
3344
- * Highlights the specified source when this source block is being converted.
3345
- *
3346
- * If the source contains callout marks, the caller assumes the source remains on the same lines and no closing tags are added to the end of each line.
3347
- * If the source gets shifted by one or more lines, this method must return a tuple containing the highlighted source and the number of lines by which the source was shifted.
3348
- *
3349
- * @param node - The source Block to syntax highlight.
3350
- * @param source - The raw source text String of this source block (after preprocessing).
3351
- * @param lang - The source language String specified on this block (e.g., ruby).
3352
- * @param opts - An object of options that configure the syntax highlighting.
3353
- *
3354
- * @returns the highlighted source String or a tuple of the highlighted source String and an Integer line offset.
3355
- */
3356
- highlight(node: Block, source: string, lang: string, opts: SyntaxHighlighterHighlightOptions): any;
3357
-
3358
- /**
3359
- * Indicates whether highlighting is handled by this syntax highlighter or by the client.
3360
- *
3361
- * @returns a Boolean indicating whether the highlight method should be used to handle the "specialchars" substitution.
3362
- */
3363
- handlesHighlighting(): boolean;
3364
-
3365
- /**
3366
- * Indicates whether this syntax highlighter has docinfo (i.e., markup) to insert into the output document at the specified location.
3367
- * Should be called by converter after main content has been converted.
3368
- *
3369
- * @param location - The String representing the location slot ("head" or "footer").
3370
- *
3371
- * @returns a Boolean indicating whether the docinfo method should be called for this location.
3372
- */
3373
- hasDocinfo(location: string): boolean;
3374
-
3375
- /**
3376
- * Generates docinfo markup for this syntax highlighter to insert at the specified location in the output document.
3377
- * Should be called by converter after main content has been converted.
3378
- *
3379
- * @param location - The String representing the location slot ("head" or "footer").
3380
- * @param doc - The Document in which this syntax highlighter is being used.
3381
- * @param opts - A Object of options that configure the syntax highlighting
3382
- * @returns the String markup to insert.
3383
- */
3384
- docinfo(location: string, doc: Document, opts: SyntaxHighlighterDocinfoOptions): string;
3385
- }
3386
-
3387
- /**
3388
- * @description
3389
- * This API is experimental and subject to change.
3390
- *
3391
- * Please note that this API is currently only available in a Node environment.
3392
- * We recommend to use a custom converter if you are running in the browser.
3393
- */
3394
- export namespace TemplateConverter {
3395
- interface CreateOptions {
3396
- [key: string]: any;
3397
-
3398
- template_engine?: string;
3399
- template_cache?: TemplateCache;
3400
- }
3401
-
3402
- interface TemplateCache {
3403
- [key: string]: any;
3404
-
3405
- /**
3406
- * a JSON of template objects keyed by template name keyed by path patterns
3407
- */
3408
- scans?: TemplatesIndexed;
3409
- /**
3410
- * a JSON of template objects keyed by file paths
3411
- */
3412
- templates?: TemplateIndexed;
3413
- }
3414
-
3415
- interface TemplatesIndexed {
3416
- [key: string]: TemplateIndexed;
3417
- }
3418
-
3419
- interface TemplateIndexed {
3420
- [key: string]: Template;
3421
- }
3422
-
3423
- /**
3424
- * Create a new {@link TemplateConverter}.
3425
- * @param backend - the backend name
3426
- * @param templateDirectories - a list of template directories
3427
- * @param [opts] - a JSON of options
3428
- * @param [opts.template_engine] - the name of the template engine
3429
- * @param [opts.template_cache] - a template cache
3430
- * @param [opts.template_cache.scans] - a JSON of template objects keyed by template name keyed by path patterns
3431
- * @param [opts.template_cache.templates] - a JSON of template objects keyed by file paths
3432
- * @returns a {@link TemplateConverter}
3433
- */
3434
- function create(backend: string, templateDirectories: string[], opts?: CreateOptions): TemplateConverter;
3435
- }
3436
-
3437
- /**
3438
- * A built-in {Converter} implementation that uses templates composed in template languages
3439
- * to convert {AbstractNode} objects from a parsed AsciiDoc document tree to the backend format.
3440
- */
3441
- export class TemplateConverter extends Converter {
3442
- /**
3443
- * @returns the global cache
3444
- */
3445
- static getCache(): TemplateConverter.TemplateCache;
3446
-
3447
- /**
3448
- * Clear the global cache.
3449
- */
3450
- static clearCache(): void;
3451
-
3452
- /**
3453
- * Convert an {AbstractNode} to the backend format using the named template.
3454
- *
3455
- * Looks for a template that matches the value of the template name or,
3456
- * if the template name is not specified, the value of the {@see AbstractNode.getNodeName} function.
3457
- *
3458
- * @param node - the AbstractNode to convert
3459
- * @param [templateName] - the {string} name of the template to use, or the node name of the node if a template name is not specified. (optional, default: undefined)
3460
- * @param [opts] - an optional JSON that is passed as local variables to the template. (optional, default: undefined)
3461
- * @returns The {string} result from rendering the template
3462
- */
3463
- convert(node: AbstractNode, templateName?: string, opts?: any): string;
3464
-
3465
- /**
3466
- * Checks whether there is a template registered with the specified name.
3467
- *
3468
- * @param name - the {string} template name
3469
- * @returns a {boolean} that indicates whether a template is registered for the specified template name.
3470
- */
3471
- handles(name: string): boolean;
3472
-
3473
- /**
3474
- * Retrieves the templates that this converter manages.
3475
- *
3476
- * @returns a JSON of template objects keyed by template name
3477
- */
3478
- getTemplates(): TemplateConverter.TemplateIndexed;
3479
-
3480
- /**
3481
- * Registers a template with this converter.
3482
- *
3483
- * @param name - the {string} template name
3484
- * @param template - the template object to register
3485
- * @returns the template object
3486
- */
3487
- register(name: string, template: Template): TemplateConverter.TemplateIndexed;
3488
- }
3489
-
3490
- /**
3491
- * A {Converter} implementation that delegates to the chain of {Converter}
3492
- * objects passed to the constructor. Selects the first {Converter} that
3493
- * identifies itself as the handler for a given transform.
3494
- */
3495
- export class CompositeConverter extends Converter {
3496
- /**
3497
- * Delegates to the first converter that identifies itself as the handler for the given transform.
3498
- * The optional Hash is passed as the last option to the delegate's convert method.
3499
- *
3500
- * @param node - the AbstractNode to convert
3501
- * @param [transform] - the optional {string} transform, or the name of the node if no transform is specified. (optional, default: undefined)
3502
- * @param [opts] - an optional JSON that is passed as local variables to the template. (optional, default: undefined)
3503
- * @returns The {string} result from the delegate's convert method
3504
- */
3505
- convert(node: AbstractNode, transform?: string, opts?: any): string;
3506
-
3507
- /**
3508
- * Checks whether there is a template registered with the specified name.
3509
- *
3510
- * @param name - the {string} template name
3511
- * @returns a {boolean} that indicates whether a template is registered for the specified template name.
3512
- */
3513
- handles(name: string): boolean;
3514
-
3515
- /**
3516
- * Retrieves the templates that this converter manages.
3517
- *
3518
- * @returns a JSON of template objects keyed by template name
3519
- */
3520
- getTemplates(): TemplateConverter.TemplateIndexed;
3521
-
3522
- /**
3523
- * Registers a template with this converter.
3524
- *
3525
- * @param name - the {string} template name
3526
- * @param template - the template object to register
3527
- * @returns the template object
3528
- */
3529
- register(name: string, template: Template): TemplateConverter.TemplateIndexed;
3530
- }
3531
-
3532
- export namespace Template {
3533
- interface Context {
3534
- node: AbstractNode;
3535
- opts?: Options;
3536
- helpers?: any;
3537
- }
3538
- }
3539
-
3540
- /**
3541
- * Handles template rendering.
3542
- */
3543
- interface Template {
3544
- [key: string]: any;
3545
-
3546
- /**
3547
- * Render the template with a given context.
3548
- * @param context - A context that contains the {AbstractNode}
3549
- * @returns The resulting {string}
3550
- */
3551
- render: (context: Template.Context) => string;
3552
- }
3553
-
3554
- export namespace TemplateEngine {
3555
- interface Registry {
3556
- [key: string]: Adapter;
3557
- }
3558
-
3559
- /**
3560
- * Handles template compilation.
3561
- */
3562
- interface Adapter {
3563
- /**
3564
- * Compile a file to a {Template}.
3565
- * @param file - The file path
3566
- * @param nodeName - The node name
3567
- */
3568
- compile: (file: string, nodeName: string) => Template;
3569
- }
3570
- }
3571
-
3572
- /**
3573
- * @description
3574
- * This API is experimental and subject to change.
3575
- *
3576
- * A global registry for integrating a template engine into the built-in template converter.
3577
- */
3578
- export class TemplateEngine {
3579
- /**
3580
- * The template engine registry.
3581
- */
3582
- registry: TemplateEngine.Registry;
3583
-
3584
- /**
3585
- * Register a template engine adapter for the given names.
3586
- * @param names - a {string} name or an {Array} of {string} names
3587
- * @param templateEngineAdapter - a template engine adapter instance
3588
- * @example
3589
- * import fs from 'fs';
3590
- * class DotTemplateEngineAdapter implements TemplateEngine.Adapter {
3591
- * private readonly doT: any;
3592
- * constructor() {
3593
- * this.doT = require('dot');
3594
- * }
3595
- * compile file: string) {
3596
- * const templateFn = this.doT.template(fs.readFileSync(file, 'utf8'));
3597
- * return {
3598
- * render: templateFn
3599
- * };
3600
- * }
3601
- * }
3602
- * processor.TemplateEngine.register('dot', new DotTemplateEngineAdapter());
3603
- */
3604
- static register(names: string | string[], templateEngineAdapter: TemplateEngine.Adapter): void;
3605
- }
3606
-
3607
- /**
3608
- * @description
3609
- * The main application interface (API) for
3610
- * This API provides methods to parse AsciiDoc content and convert it to various output formats using built-in or third-party converters.
3611
- *
3612
- * An AsciiDoc document can be as simple as a single line of content,
3613
- * though it more commonly starts with a document header that declares the document title and document attribute definitions.
3614
- * The document header is then followed by zero or more section titles, optionally nested, to organize the paragraphs, blocks, lists, etc. of the document.
3615
- *
3616
- * By default, the processor converts the AsciiDoc document to HTML 5 using a built-in converter.
3617
- * However, this behavior can be changed by specifying a different backend (e.g., +docbook+).
3618
- * A backend is a keyword for an output format (e.g., DocBook).
3619
- * That keyword, in turn, is used to select a converter, which carries out the request to convert the document to that format.
3620
- *
3621
- * @example
3622
- * asciidoctor.convertFile('document.adoc', { 'safe': 'safe' }) // Convert an AsciiDoc file
3623
- *
3624
- * asciidoctor.convert("I'm using *Asciidoctor* version {asciidoctor-version}.", { 'safe': 'safe' }) // Convert an AsciiDoc string
3625
- *
3626
- * const doc = asciidoctor.loadFile('document.adoc', { 'safe': 'safe' }) // Parse an AsciiDoc file into a document object
3627
- *
3628
- * const doc = asciidoctor.load("= Document Title\n\nfirst paragraph\n\nsecond paragraph", { 'safe': 'safe' }) // Parse an AsciiDoc string into a document object
3629
- */
3630
- export class Asciidoctor {
3631
- /**
3632
- * Get Asciidoctor core version number.
3633
- *
3634
- * @returns the version number of Asciidoctor core.
3635
- */
3636
- getCoreVersion(): string;
3637
-
3638
- /**
3639
- * Get js runtime environment information.
3640
- *
3641
- * @returns the runtime environment including the ioModule, the platform, the engine and the framework.
3642
- */
3643
- getRuntime(): Runtime;
3644
-
3645
- /**
3646
- * Parse the AsciiDoc source input into an {@link Document} and convert it to the specified backend format.
3647
- *
3648
- * Accepts input as a Buffer or String.
3649
- *
3650
- * @param input - AsciiDoc input as String or Buffer
3651
- * @param options - a JSON of options to control processing (default: {})
3652
- * @returns the {@link Document} object if the converted String is written to a file,
3653
- * otherwise the converted String
3654
- * @example
3655
- * var input = '= Hello, AsciiDoc!\n' +
3656
- * 'Guillaume Grossetie <ggrossetie@example.com>\n\n' +
3657
- * 'An introduction to http://asciidoc.org[AsciiDoc].\n\n' +
3658
- * '== First Section\n\n' +
3659
- * '* item 1\n' +
3660
- * '* item 2\n';
3661
- *
3662
- * var html = asciidoctor.convert(input);
3663
- */
3664
- convert(input: string | Buffer, options?: ProcessorOptions): string | Document;
3665
-
3666
- /**
3667
- * Parse the AsciiDoc source input into an {@link Document} and convert it to the specified backend format.
3668
- *
3669
- * @param filename - source filename
3670
- * @param options - a JSON of options to control processing (default: {})
3671
- * @returns the {@link Document} object if the converted String is written to a file,
3672
- * otherwise the converted String
3673
- * @example
3674
- * var html = asciidoctor.convertFile('./document.adoc');
3675
- */
3676
- convertFile(filename: string, options?: ProcessorOptions): string | Document;
3677
-
3678
- /**
3679
- * Parse the AsciiDoc source input into an {@link Document}
3680
- *
3681
- * Accepts input as a Buffer or String.
3682
- *
3683
- * @param input - AsciiDoc input as String or Buffer
3684
- * @param options - a JSON of options to control processing (default: {})
3685
- * @returns the {@link Document} object
3686
- */
3687
- load(input: string | Buffer, options?: ProcessorOptions): Document;
3688
-
3689
- /**
3690
- * Parse the contents of the AsciiDoc source file into an {@link Document}
3691
- *
3692
- * @param filename - source filename
3693
- * @param options - a JSON of options to control processing (default: {})
3694
- * @returns the {@link Document} object
3695
- */
3696
- loadFile(filename: string, options?: ProcessorOptions): Document;
3697
-
3698
- /**
3699
- * Get js version number.
3700
- *
3701
- * @returns the version number of js.
3702
- */
3703
- getVersion(): string;
3704
-
3705
- Block: typeof Block;
3706
-
3707
- Section: typeof Section;
3708
-
3709
- SafeMode: typeof SafeMode;
3710
-
3711
- Extensions: typeof Extensions;
3712
-
3713
- Html5Converter: typeof Html5Converter;
3714
-
3715
- TemplateConverter: typeof TemplateConverter;
3716
-
3717
- ConverterFactory: ConverterFactory;
3718
-
3719
- MemoryLogger: typeof MemoryLogger;
3720
-
3721
- NullLogger: typeof MemoryLogger;
3722
-
3723
- Timings: typeof Timings;
3724
-
3725
- LoggerManager: typeof LoggerManager;
3726
-
3727
- SyntaxHighlighter: typeof SyntaxHighlighter;
3728
-
3729
- TemplateEngine: typeof TemplateEngine;
3730
- }
3731
-
3732
- export default function asciidoctor(): Asciidoctor;
2
+ * Get the version of Asciidoctor.js.
3
+ *
4
+ * @returns {string} - the version of Asciidoctor.js
5
+ */
6
+ export function getVersion(): string;
7
+ /**
8
+ * Get Asciidoctor core version number.
9
+ *
10
+ * @returns {string} - the version of Asciidoctor core (Ruby)
11
+ */
12
+ export function getCoreVersion(): string;
13
+ /**
14
+ * Parse the AsciiDoc source input into a Document.
15
+ *
16
+ * @param {string|string[]|Buffer} input - the AsciiDoc source as a String, String Array, or Buffer
17
+ * @param {Object} [options={}] - a plain object of options to control processing
18
+ * @returns {Promise<Document>} - the parsed Document
19
+ */
20
+ export function load(input: string | string[] | Buffer, options?: any): Promise<Document>;
21
+ /**
22
+ * Parse the contents of the AsciiDoc source file into a Document.
23
+ *
24
+ * @param {string} filename - the path to the AsciiDoc source file
25
+ * @param {Object} [options={}] - a plain object of options to control processing
26
+ * @returns {Promise<Document>} - the parsed Document
27
+ */
28
+ export function loadFile(filename: string, options?: any): Promise<Document>;
29
+ import { Document } from './document.js';
30
+ import { convert } from './convert.js';
31
+ import { convertFile } from './convert.js';
32
+ import { DocumentTitle } from './document.js';
33
+ import { Author } from './document.js';
34
+ import { Footnote } from './document.js';
35
+ import { ImageReference } from './document.js';
36
+ import { RevisionInfo } from './document.js';
37
+ import { Logger } from './logging.js';
38
+ import { AbstractNode } from './abstract_node.js';
39
+ import { AbstractBlock } from './abstract_block.js';
40
+ import { Inline } from './inline.js';
41
+ import { Block } from './block.js';
42
+ import { List } from './list.js';
43
+ import { ListItem } from './list.js';
44
+ import { Section } from './section.js';
45
+ import { Reader } from './reader.js';
46
+ import { SyntaxHighlighterBase } from './syntax_highlighter.js';
47
+ import { LoggerManager } from './logging.js';
48
+ import { MemoryLogger } from './logging.js';
49
+ import { NullLogger } from './logging.js';
50
+ import { SafeMode } from './constants.js';
51
+ import { ContentModel } from './constants.js';
52
+ import { Timings } from './timings.js';
53
+ import { Registry } from './extensions.js';
54
+ import { Processor } from './extensions.js';
55
+ import { ProcessorExtension } from './extensions.js';
56
+ import { Preprocessor } from './extensions.js';
57
+ import { TreeProcessor } from './extensions.js';
58
+ import { Postprocessor } from './extensions.js';
59
+ import { IncludeProcessor } from './extensions.js';
60
+ import { DocinfoProcessor } from './extensions.js';
61
+ import { BlockProcessor } from './extensions.js';
62
+ import { InlineMacroProcessor } from './extensions.js';
63
+ import { BlockMacroProcessor } from './extensions.js';
64
+ import { Extensions } from './extensions.js';
65
+ import { Cursor } from './reader.js';
66
+ import { Converter } from './converter.js';
67
+ import { ConverterBase } from './converter.js';
68
+ import { CustomFactory } from './converter.js';
69
+ import { DefaultFactory as DefaultConverterFactory } from './converter.js';
70
+ import { deriveBackendTraits } from './converter.js';
71
+ import { DefaultFactory as DefaultSyntaxHighlighterFactory } from './syntax_highlighter.js';
72
+ import Html5Converter from './converter/html5.js';
73
+ import { SyntaxHighlighter } from './syntax_highlighter.js';
74
+ 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 };