@asciidoctor/core 3.0.4 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +42 -10
  2. package/build/browser/index.js +24154 -0
  3. package/build/node/index.cjs +24735 -0
  4. package/{dist/css/asciidoctor.css → data/asciidoctor-default.css} +54 -53
  5. package/package.json +53 -100
  6. package/src/abstract_block.js +849 -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 +1899 -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 +343 -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.ts +73 -3731
  69. package/types/inline.d.ts +69 -0
  70. package/types/list.d.ts +114 -0
  71. package/types/load.d.ts +39 -0
  72. package/types/logging.d.ts +187 -0
  73. package/types/parser.d.ts +114 -0
  74. package/types/path_resolver.d.ts +103 -0
  75. package/types/reader.d.ts +184 -0
  76. package/types/rx.d.ts +513 -0
  77. package/types/section.d.ts +122 -0
  78. package/types/stylesheets.d.ts +10 -0
  79. package/types/substitutors.d.ts +208 -0
  80. package/types/syntaxHighlighter/highlightjs.d.ts +33 -0
  81. package/types/syntaxHighlighter/html_pipeline.d.ts +16 -0
  82. package/types/syntax_highlighter.d.ts +167 -0
  83. package/types/table.d.ts +231 -0
  84. package/types/timings.d.ts +25 -0
  85. package/types/tsconfig.json +9 -0
  86. package/LICENSE +0 -21
  87. package/dist/browser/asciidoctor.js +0 -47654
  88. package/dist/browser/asciidoctor.min.js +0 -1452
  89. package/dist/graalvm/asciidoctor.js +0 -47402
  90. package/dist/node/asciidoctor.cjs +0 -21567
  91. package/dist/node/asciidoctor.js +0 -23037
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Methods for managing sections of AsciiDoc content in a document.
3
+ */
4
+ export class Section extends AbstractBlock<string> {
5
+ /**
6
+ * Create a new Section — mirrors the core Section.create() API.
7
+ * @param {AbstractBlock|null} [parent=null]
8
+ * @param {number|null} [level=null]
9
+ * @param {boolean} [numbered=false]
10
+ * @param {Object} [opts={}]
11
+ * @returns {Section}
12
+ */
13
+ static create(parent?: AbstractBlock | null, level?: number | null, numbered?: boolean, opts?: any): Section;
14
+ /**
15
+ * Generate a String ID from the given section title.
16
+ * @param {string} title - The String title.
17
+ * @param {object} document - The Document.
18
+ * @returns {string} the generated String ID.
19
+ */
20
+ static generateId(title: string, document: object): string;
21
+ /**
22
+ * Initialize an Asciidoctor Section object.
23
+ * @param {AbstractBlock|null} [parent=null] - The parent AbstractBlock (Document or Section), or null.
24
+ * @param {number|null} [level=null] - The Integer level of this section (default: parent.level + 1 or 1).
25
+ * @param {boolean} [numbered=false] - Boolean indicating whether numbering is enabled.
26
+ * @param {Object} [opts={}] - An optional plain object of options.
27
+ */
28
+ constructor(parent?: AbstractBlock | null, level?: number | null, numbered?: boolean, opts?: any);
29
+ special: boolean;
30
+ numbered: boolean;
31
+ index: number;
32
+ sectname: string;
33
+ /**
34
+ * The name of this section — alias for title.
35
+ * @returns {string|null}
36
+ */
37
+ get name(): string | null;
38
+ /**
39
+ * Generate a String ID from the title of this section.
40
+ * This sync convenience method is only called outside of parsing (e.g. extensions).
41
+ * At that point #convertedTitle is already set, so this.title returns the fully-substituted
42
+ * HTML title — matching Ruby's behaviour where section.title calls apply_title_subs.
43
+ * @returns {string}
44
+ */
45
+ generateId(): string;
46
+ /**
47
+ * Get the section number for the current Section as a dot-separated String.
48
+ * @param {string} [delimiter='.'] - The separator between numerals.
49
+ * @param {string|false|null} [append=null] - String appended at the end, or false to omit trailing delimiter
50
+ * (default: null → same as delimiter).
51
+ * @returns {string} the section number String.
52
+ */
53
+ sectnum(delimiter?: string, append?: string | false | null): string;
54
+ /**
55
+ * Append a content block to this block's list of blocks.
56
+ * If the child block is a Section, assign an index/numeral to it.
57
+ * @param {AbstractBlock} block - The child Block to append.
58
+ * @returns {this}
59
+ */
60
+ append(block: AbstractBlock): this;
61
+ /**
62
+ * Get the section title (alias of title).
63
+ * @returns {string|null}
64
+ */
65
+ getName(): string | null;
66
+ /**
67
+ * Get the section name (e.g. 'section', 'appendix').
68
+ * @returns {string|null}
69
+ */
70
+ getSectionName(): string | null;
71
+ /**
72
+ * Set the section name (e.g. 'section', 'appendix').
73
+ * @param {string|null} val
74
+ */
75
+ setSectionName(val: string | null): void;
76
+ /**
77
+ * Get the 0-based index of this section within the parent block.
78
+ * @returns {number}
79
+ */
80
+ getIndex(): number;
81
+ /**
82
+ * Set the 0-based index of this section within the parent block.
83
+ * @param {number} val
84
+ */
85
+ setIndex(val: number): void;
86
+ /**
87
+ * Get whether this section is numbered.
88
+ * @returns {boolean}
89
+ */
90
+ isNumbered(): boolean;
91
+ /**
92
+ * Get whether this section is a special section.
93
+ * @returns {boolean}
94
+ */
95
+ isSpecial(): boolean;
96
+ /**
97
+ * Set whether this section is a special section.
98
+ * @param {boolean} val
99
+ */
100
+ setSpecial(val: boolean): void;
101
+ /**
102
+ * Get the section numeral string.
103
+ * @returns {string|null}
104
+ */
105
+ getNumeral(): string | null;
106
+ /**
107
+ * Set the section numeral string.
108
+ * @param {string|null} val
109
+ */
110
+ setNumeral(val: string | null): void;
111
+ /**
112
+ * Get the section number string (dot-separated).
113
+ * @returns {string}
114
+ */
115
+ getSectionNumeral(): string;
116
+ /**
117
+ * Get the section number string (alias of getSectionNumeral).
118
+ * @returns {string}
119
+ */
120
+ getSectionNumber(): string;
121
+ }
122
+ import { AbstractBlock } from './abstract_block.js';
@@ -0,0 +1,10 @@
1
+ export namespace Stylesheets {
2
+ let instance: StylesheetsClass;
3
+ }
4
+ declare class StylesheetsClass {
5
+ static DEFAULT_STYLESHEET_NAME: string;
6
+ get primaryStylesheetName(): string;
7
+ primaryStylesheetData(): Promise<string>;
8
+ embedPrimaryStylesheet(): Promise<string>;
9
+ }
10
+ export {};
@@ -0,0 +1,208 @@
1
+ export namespace Substitutors {
2
+ /**
3
+ * Apply the specified substitutions to the text.
4
+ *
5
+ * @param {string|string[]} text - The text to process; must not be null.
6
+ * @param {string[]} [subs=NORMAL_SUBS] - The substitutions to perform.
7
+ * @returns {string|string[]} Text with substitutions applied.
8
+ */
9
+ function applySubs(text: string | string[], subs?: string[]): string | string[];
10
+ /** Apply normal substitutions (alias for applySubs with default args). */
11
+ function applyNormalSubs(text: any): Promise<string | string[]>;
12
+ /** Apply substitutions for header metadata and attribute assignments.
13
+ * Header subs are 'specialcharacters' + 'attributes', both of which are
14
+ * purely synchronous operations — so this method is intentionally sync
15
+ * to allow it to be called from synchronous contexts such as setAttribute()
16
+ * and the {set:...} directive inside subAttributes(). */
17
+ function applyHeaderSubs(text: any): string;
18
+ /** Apply substitutions for titles (alias for applySubs). */
19
+ function applyTitleSubs(text: any, subs?: readonly string[]): Promise<string | string[]>;
20
+ /** Apply substitutions for reftext. */
21
+ function applyReftextSubs(text: any): Promise<string | string[]>;
22
+ /**
23
+ * Substitute special characters (encode XML entities).
24
+ *
25
+ * @param {string} text
26
+ * @returns {string}
27
+ */
28
+ function subSpecialchars(text: string): string;
29
+ /** Alias for subSpecialchars. */
30
+ function subSpecialcharacters(text: any): string;
31
+ /**
32
+ * Substitute quoted text (emphasis, strong, monospaced, etc.)
33
+ *
34
+ * @param {string} text
35
+ * @returns {string}
36
+ */
37
+ function subQuotes(text: string): string;
38
+ /**
39
+ * Substitute attribute references in the specified text.
40
+ *
41
+ * @param {string} text
42
+ * @param {Object} [opts={}]
43
+ * @returns {string}
44
+ */
45
+ function subAttributes(text: string, opts?: any): string;
46
+ /**
47
+ * Substitute replacement characters (copyright, trademark, etc.)
48
+ *
49
+ * @param {string} text
50
+ * @returns {string}
51
+ */
52
+ function subReplacements(text: string): string;
53
+ /**
54
+ * Substitute inline macros (links, images, etc.)
55
+ *
56
+ * @param {string} text
57
+ * @returns {string}
58
+ */
59
+ function subMacros(text: string): string;
60
+ /**
61
+ * Substitute post replacements (hard line breaks).
62
+ *
63
+ * @param {string} text
64
+ * @returns {string}
65
+ */
66
+ function subPostReplacements(text: string): string;
67
+ /**
68
+ * Apply verbatim substitutions on source.
69
+ *
70
+ * @param {string} source
71
+ * @param {boolean} processCallouts
72
+ * @returns {string}
73
+ */
74
+ function subSource(source: string, processCallouts: boolean): string;
75
+ /**
76
+ * Substitute callout source references.
77
+ *
78
+ * @param {string} text
79
+ * @returns {string}
80
+ */
81
+ function subCallouts(text: string): string;
82
+ /**
83
+ * Highlight (colorize) the source code using a syntax highlighter.
84
+ *
85
+ * @param {string} source
86
+ * @param {boolean} processCallouts
87
+ * @returns {string}
88
+ */
89
+ function highlightSource(source: string, processCallouts: boolean): string;
90
+ /**
91
+ * Resolve line numbers to highlight from a test string.
92
+ *
93
+ * @param {string} source
94
+ * @param {string} spec - e.g. "1-5, !2, 10" or "1..5;!2;10"
95
+ * @param {number|null} [start=null]
96
+ * @returns {number[]}
97
+ */
98
+ function resolveLinesToHighlight(source: string, spec: string, start?: number | null): number[];
99
+ /**
100
+ * Extract passthrough text for reinsertion after processing.
101
+ *
102
+ * @param {string} text
103
+ * @returns {string} Text with passthrough regions replaced by placeholders.
104
+ */
105
+ function extractPassthroughs(text: string): string;
106
+ /**
107
+ * Restore passthrough text by reinserting into placeholder positions.
108
+ *
109
+ * @param {string} text
110
+ * @returns {string}
111
+ */
112
+ function restorePassthroughs(text: string): string;
113
+ /**
114
+ * Resolve the list of comma-delimited subs against the possible options.
115
+ *
116
+ * @param {string} subs
117
+ * @param {'block'|'inline'} [type='block']
118
+ * @param {string[]|null} [defaults=null]
119
+ * @param {string|null} [subject=null]
120
+ * @returns {string[]|undefined}
121
+ */
122
+ function resolveSubs(subs: string, type?: "block" | "inline", defaults?: string[] | null, subject?: string | null): string[] | undefined;
123
+ /** Call resolveSubs for the 'block' type. */
124
+ function resolveBlockSubs(subs: any, defaults: any, subject: any): string[];
125
+ /** Call resolveSubs for the 'inline' type with subject set as passthrough macro. */
126
+ function resolvePassSubs(subs: any, subject?: string): string[];
127
+ /**
128
+ * Expand all groups in the subs list and return.
129
+ *
130
+ * @param {string|string[]} subs
131
+ * @param {string|null} [subject=null]
132
+ * @returns {string[]|null}
133
+ */
134
+ function expandSubs(subs: string | string[], subject?: string | null): string[] | null;
135
+ /**
136
+ * Commit the requested substitutions to this block.
137
+ * Looks for an attribute named "subs". If present, resolves substitutions.
138
+ */
139
+ function commitSubs(): any;
140
+ /**
141
+ * Parse attributes in name or name=value format from a comma-separated String.
142
+ *
143
+ * @param {string} attrlist
144
+ * @param {string[]} [posattrs=[]]
145
+ * @param {Object} [opts={}]
146
+ * @returns {Object}
147
+ */
148
+ function parseAttributes(attrlist: string, posattrs?: string[], opts?: any): any;
149
+ function extractAttributesFromText(text: any, defaultText?: any): Promise<any[]>;
150
+ function extractCallouts(source: any): any[];
151
+ function restoreCallouts(source: any, calloutMarks: any, sourceOffset?: any): Promise<string>;
152
+ function convertQuotedText(args: any, type: any, scope: any): Promise<any>;
153
+ function doReplacement(match: any, replacement: any, restore: any): any;
154
+ /** Inserts text into a formatted text enclosure (sprintf). */
155
+ function subPlaceholder(format: any, ...args: any[]): any;
156
+ function parseQuotedTextAttributes(str: any): {};
157
+ function normalizeText(text: any, normalizeWhitespace?: any, unescapeClosingSquareBrackets?: any): any;
158
+ function splitSimpleCsv(str: any): any;
159
+ }
160
+ import { BASIC_SUBS } from './constants.js';
161
+ export const HEADER_SUBS: readonly string[];
162
+ export const NO_SUBS: readonly any[];
163
+ import { NORMAL_SUBS } from './constants.js';
164
+ export const REFTEXT_SUBS: readonly string[];
165
+ export const VERBATIM_SUBS: readonly string[];
166
+ export namespace SUB_GROUPS {
167
+ export { NO_SUBS as none };
168
+ export { NORMAL_SUBS as normal };
169
+ export { VERBATIM_SUBS as verbatim };
170
+ export { BASIC_SUBS as specialchars };
171
+ }
172
+ export namespace SUB_HINTS {
173
+ let a: string;
174
+ let m: string;
175
+ let n: string;
176
+ let p: string;
177
+ let q: string;
178
+ let r: string;
179
+ let c: string;
180
+ let v: string;
181
+ }
182
+ export namespace SUB_OPTIONS {
183
+ let block: string[];
184
+ let inline: string[];
185
+ }
186
+ export const CAN: "\u0018";
187
+ export const DEL: "";
188
+ export const PASS_START: "\u0096";
189
+ export const PASS_END: "\u0097";
190
+ export const PASS_SLOT_RX: RegExp;
191
+ export const HIGHLIGHTED_PASS_SLOT_RX: RegExp;
192
+ export const RS: "\\";
193
+ export const R_SB: "]";
194
+ export const ESC_R_SB: "\\]";
195
+ export const PLUS: "+";
196
+ export const SPECIAL_CHARS_RX: RegExp;
197
+ export const SPECIAL_CHARS_TR: {
198
+ '>': string;
199
+ '<': string;
200
+ '&': string;
201
+ };
202
+ export namespace QUOTED_TEXT_SNIFF_RX {
203
+ let _false: RegExp;
204
+ export { _false as false };
205
+ let _true: RegExp;
206
+ export { _true as true };
207
+ }
208
+ export { BASIC_SUBS, NORMAL_SUBS };
@@ -0,0 +1,33 @@
1
+ export class HighlightJsAdapter extends SyntaxHighlighterBase {
2
+ constructor(...args: any[]);
3
+ /**
4
+ * Wrap the source block in `<pre><code>` with highlight.js CSS classes.
5
+ *
6
+ * Adds `language-<lang>` and `hljs` to the `<code>` class attribute, and strips
7
+ * the `highlight` class from `<pre>` when the `nohighlight-option` attribute is set.
8
+ * @param {object} node - the source Block being processed
9
+ * @param {string|null} lang - the source language string, or falsy if none
10
+ * @param {object} opts - options passed to the base format()
11
+ * @returns {Promise<string>}
12
+ */
13
+ format(node: object, lang: string | null, opts: object): Promise<string>;
14
+ /**
15
+ * Always returns true — highlight.js injects markup into the document.
16
+ * @param {string} location - 'head' or 'footer'
17
+ * @returns {true}
18
+ */
19
+ hasDocinfo(location: string): true;
20
+ /**
21
+ * Returns the CSS `<link>` tag (head) or the `<script>` tags (footer).
22
+ * @param {string} location - 'head' or 'footer'
23
+ * @param {object} doc - the Document being converted
24
+ * @param {{ cdn_base_url: string, self_closing_tag_slash: string }} opts
25
+ * @returns {string}
26
+ */
27
+ docinfo(location: string, doc: object, opts: {
28
+ cdn_base_url: string;
29
+ self_closing_tag_slash: string;
30
+ }): string;
31
+ }
32
+ export default HighlightJsAdapter;
33
+ import { SyntaxHighlighterBase } from '../syntax_highlighter.js';
@@ -0,0 +1,16 @@
1
+ export class HtmlPipelineAdapter extends SyntaxHighlighterBase {
2
+ constructor(...args: any[]);
3
+ /**
4
+ * Wrap the source block in `<pre><code>` without highlight classes.
5
+ *
6
+ * The html-pipeline gem processes the markup downstream, so only a bare
7
+ * `<pre lang="<lang>"><code>` wrapper is emitted (no CSS classes, no data-lang).
8
+ * @param {object} node - the source Block being processed
9
+ * @param {string|null} lang - the source language string, or falsy if none
10
+ * @param {object} opts - options (unused by this adapter)
11
+ * @returns {Promise<string>} the wrapped source string
12
+ */
13
+ format(node: object, lang: string | null, opts: object): Promise<string>;
14
+ }
15
+ export default HtmlPipelineAdapter;
16
+ import { SyntaxHighlighterBase } from '../syntax_highlighter.js';
@@ -0,0 +1,167 @@
1
+ /** @import { Block } from './block.js' */
2
+ /**
3
+ * Base class for syntax highlighter adapters.
4
+ *
5
+ * Subclasses should override the methods they need. Two usage patterns:
6
+ * 1. Server-side highlighting: override `handlesHighlighting()` → true and `highlight()`.
7
+ * 2. Client-side highlighting: override `hasDocinfo()` → true and `docinfo()`.
8
+ *
9
+ * Both patterns may also override `format()`.
10
+ */
11
+ export class SyntaxHighlighterBase {
12
+ /**
13
+ * @param {string} name - the name identifying this adapter
14
+ * @param {string} [backend='html5'] - the backend name
15
+ * @param {Object} [opts={}] - options
16
+ */
17
+ constructor(name: string, backend?: string, opts?: any);
18
+ name: string;
19
+ _preClass: string;
20
+ /**
21
+ * Indicates whether this highlighter has docinfo markup to insert at the specified location.
22
+ *
23
+ * @param {string} location - the location slot ('head' or 'footer')
24
+ * @returns {boolean} false by default; subclasses return true to enable {@link docinfo}
25
+ */
26
+ hasDocinfo(location: string): boolean;
27
+ /**
28
+ * Generates docinfo markup to insert at the specified location in the output document.
29
+ *
30
+ * @param {string} location - the location slot ('head' or 'footer')
31
+ * @param {Document} doc - the Document in which this highlighter is used
32
+ * @param {Object} opts - options
33
+ * @param {boolean} [opts.linkcss] - link stylesheet instead of embedding
34
+ * @param {string} [opts.cdn_base_url] - base URL for CDN assets
35
+ * @param {string} [opts.self_closing_tag_slash] - '/' for self-closing tags
36
+ * @returns {string} the markup to insert
37
+ */
38
+ docinfo(location: string, doc: Document, opts: {
39
+ linkcss?: boolean;
40
+ cdn_base_url?: string;
41
+ self_closing_tag_slash?: string;
42
+ }): string;
43
+ /**
44
+ * Indicates whether highlighting is handled server-side by this highlighter.
45
+ *
46
+ * @returns {boolean} false by default; subclasses return true to enable {@link highlight}
47
+ */
48
+ handlesHighlighting(): boolean;
49
+ /**
50
+ * Highlights the specified source when this source block is being converted.
51
+ *
52
+ * If the source contains callout marks, the caller assumes the source remains on the same
53
+ * lines and no closing tags are added to the end of each line. If the source gets shifted
54
+ * by one or more lines, return a tuple of the highlighted source and the line offset.
55
+ *
56
+ * @param {Block} node - the source Block to highlight
57
+ * @param {string} source - the raw source text
58
+ * @param {string} lang - the source language (e.g. 'ruby')
59
+ * @param {Object} opts - options
60
+ * @param {Object} [opts.callouts] - callouts indexed by line number
61
+ * @param {string} [opts.css_mode] - CSS mode ('class' or 'inline')
62
+ * @param {number[]} [opts.highlight_lines] - 1-based line numbers to emphasize
63
+ * @param {string} [opts.number_lines] - 'table' or 'inline' if lines should be numbered
64
+ * @param {number} [opts.start_line_number] - starting line number (default: 1)
65
+ * @param {string} [opts.style] - theme name
66
+ * @returns {string|[string, number]} the highlighted source, or a tuple with a line offset
67
+ */
68
+ highlight(node: Block, source: string, lang: string, opts: {
69
+ callouts?: any;
70
+ css_mode?: string;
71
+ highlight_lines?: number[];
72
+ number_lines?: string;
73
+ start_line_number?: number;
74
+ style?: string;
75
+ }): string | [string, number];
76
+ /**
77
+ * Formats the highlighted source for inclusion in an HTML document.
78
+ *
79
+ * @param {Block} node - the source Block being processed
80
+ * @param {string} lang - the source language (e.g. 'ruby')
81
+ * @param {Object} opts - options
82
+ * @param {boolean} [opts.nowrap] - disable line wrapping
83
+ * @param {Function} [opts.transform] - called with (pre, code) attribute objects before building tags
84
+ * @returns {Promise<string>|string} the highlighted source wrapped in &lt;pre&gt;&lt;code&gt; tags.
85
+ * Subclasses may return a plain `string` — the caller always `await`s the result.
86
+ */
87
+ format(node: Block, lang: string, opts: {
88
+ nowrap?: boolean;
89
+ transform?: Function;
90
+ }): Promise<string> | string;
91
+ /**
92
+ * Indicates whether this highlighter wants to write a stylesheet to disk.
93
+ *
94
+ * @param {Document} doc - the Document in which this highlighter is being used
95
+ * @returns {boolean} false by default; subclasses return true to enable {@link writeStylesheetToDisk}
96
+ */
97
+ writeStylesheet(doc: Document): boolean;
98
+ /**
99
+ * Writes the stylesheet to disk.
100
+ *
101
+ * @param {Document} doc - the Document in which this highlighter is used
102
+ * @param {string} toDir - the absolute path of the output directory
103
+ */
104
+ writeStylesheetToDisk(doc: Document, toDir: string): void;
105
+ }
106
+ /**
107
+ * A syntax highlighter factory backed by a caller-supplied registry.
108
+ */
109
+ export class CustomFactory {
110
+ /**
111
+ * @param {Object|null} [seedRegistry=null] - initial registry entries
112
+ */
113
+ constructor(seedRegistry?: any | null);
114
+ _registry: any;
115
+ /**
116
+ * Associates a syntax highlighter class or instance with one or more names.
117
+ *
118
+ * @param {Function|SyntaxHighlighterBase} syntaxHighlighter - the class or instance to register
119
+ * @param {...string} names - one or more names to associate
120
+ */
121
+ register(syntaxHighlighter: Function | SyntaxHighlighterBase, ...names: string[]): void;
122
+ /**
123
+ * Retrieves the syntax highlighter class or instance registered for the given name.
124
+ *
125
+ * @param {string} name - the name to look up
126
+ * @returns {Function|SyntaxHighlighterBase|null} the registered class or instance, or null
127
+ */
128
+ for(name: string): Function | SyntaxHighlighterBase | null;
129
+ /**
130
+ * Resolves a name to a syntax highlighter instance.
131
+ *
132
+ * @param {string} name - the name of the syntax highlighter
133
+ * @param {string} [backend='html5'] - the backend name
134
+ * @param {Object} [opts={}] - options passed to the constructor
135
+ * @returns {SyntaxHighlighterBase|null} a highlighter instance, or null if not registered
136
+ */
137
+ create(name: string, backend?: string, opts?: any): SyntaxHighlighterBase | null;
138
+ }
139
+ export class DefaultFactoryProxy extends CustomFactory {
140
+ /**
141
+ * @param {Object} overrides - map of name → class/instance/null
142
+ * @param {CustomFactory} fallback - factory to delegate to when name is not overridden
143
+ */
144
+ constructor(overrides: any, fallback: CustomFactory);
145
+ _fallback: CustomFactory;
146
+ for(name: any): any;
147
+ }
148
+ export class DefaultFactory extends CustomFactory {
149
+ constructor();
150
+ _defaultRegistry: {};
151
+ register(syntaxHighlighter: any, ...names: any[]): void;
152
+ for(name: any): any;
153
+ /**
154
+ * Retrieves the syntax highlighter class or instance registered for the given name.
155
+ *
156
+ * @param {string} name - the name of the syntax highlighter to retrieve
157
+ * @returns {Function|SyntaxHighlighterBase|undefined} the registered class or instance, or undefined
158
+ */
159
+ get(name: string): Function | SyntaxHighlighterBase | undefined;
160
+ create(name: any, backend?: string, opts?: {}): any;
161
+ /**
162
+ * Clears all custom (user) registrations; built-in adapters are preserved.
163
+ */
164
+ unregisterAll(): void;
165
+ }
166
+ export const SyntaxHighlighter: DefaultFactory;
167
+ import type { Block } from './block.js';