marked 9.1.2 → 9.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/marked.d.ts CHANGED
@@ -1,616 +1,509 @@
1
- declare module "Tokens" {
2
- export type Token = (Tokens.Space | Tokens.Code | Tokens.Heading | Tokens.Table | Tokens.Hr | Tokens.Blockquote | Tokens.List | Tokens.ListItem | Tokens.Paragraph | Tokens.HTML | Tokens.Text | Tokens.Def | Tokens.Escape | Tokens.Tag | Tokens.Image | Tokens.Link | Tokens.Strong | Tokens.Em | Tokens.Codespan | Tokens.Br | Tokens.Del | Tokens.Generic);
3
- export namespace Tokens {
4
- interface Space {
5
- type: 'space';
6
- raw: string;
7
- }
8
- interface Code {
9
- type: 'code';
10
- raw: string;
11
- codeBlockStyle?: 'indented' | undefined;
12
- lang?: string | undefined;
13
- text: string;
14
- escaped?: boolean;
15
- }
16
- interface Heading {
17
- type: 'heading';
18
- raw: string;
19
- depth: number;
20
- text: string;
21
- tokens: Token[];
22
- }
23
- interface Table {
24
- type: 'table';
25
- raw: string;
26
- align: Array<'center' | 'left' | 'right' | null>;
27
- header: TableCell[];
28
- rows: TableCell[][];
29
- }
30
- interface TableCell {
31
- text: string;
32
- tokens: Token[];
33
- }
34
- interface Hr {
35
- type: 'hr';
36
- raw: string;
37
- }
38
- interface Blockquote {
39
- type: 'blockquote';
40
- raw: string;
41
- text: string;
42
- tokens: Token[];
43
- }
44
- interface List {
45
- type: 'list';
46
- raw: string;
47
- ordered: boolean;
48
- start: number | '';
49
- loose: boolean;
50
- items: ListItem[];
51
- }
52
- interface ListItem {
53
- type: 'list_item';
54
- raw: string;
55
- task: boolean;
56
- checked?: boolean | undefined;
57
- loose: boolean;
58
- text: string;
59
- tokens: Token[];
60
- }
61
- interface Paragraph {
62
- type: 'paragraph';
63
- raw: string;
64
- pre?: boolean | undefined;
65
- text: string;
66
- tokens: Token[];
67
- }
68
- interface HTML {
69
- type: 'html';
70
- raw: string;
71
- pre: boolean;
72
- text: string;
73
- block: boolean;
74
- }
75
- interface Text {
76
- type: 'text';
77
- raw: string;
78
- text: string;
79
- tokens?: Token[];
80
- }
81
- interface Def {
82
- type: 'def';
83
- raw: string;
84
- tag: string;
85
- href: string;
86
- title: string;
87
- }
88
- interface Escape {
89
- type: 'escape';
90
- raw: string;
91
- text: string;
92
- }
93
- interface Tag {
94
- type: 'text' | 'html';
95
- raw: string;
96
- inLink: boolean;
97
- inRawBlock: boolean;
98
- text: string;
99
- block: boolean;
100
- }
101
- interface Link {
102
- type: 'link';
103
- raw: string;
104
- href: string;
105
- title?: string | null;
106
- text: string;
107
- tokens: Token[];
108
- }
109
- interface Image {
110
- type: 'image';
111
- raw: string;
112
- href: string;
113
- title: string | null;
114
- text: string;
115
- }
116
- interface Strong {
117
- type: 'strong';
118
- raw: string;
119
- text: string;
120
- tokens: Token[];
121
- }
122
- interface Em {
123
- type: 'em';
124
- raw: string;
125
- text: string;
126
- tokens: Token[];
127
- }
128
- interface Codespan {
129
- type: 'codespan';
130
- raw: string;
131
- text: string;
132
- }
133
- interface Br {
134
- type: 'br';
135
- raw: string;
136
- }
137
- interface Del {
138
- type: 'del';
139
- raw: string;
140
- text: string;
141
- tokens: Token[];
142
- }
143
- interface Generic {
144
- [index: string]: any;
145
- type: string;
146
- raw: string;
147
- tokens?: Token[] | undefined;
148
- }
149
- }
150
- export type Links = Record<string, Pick<Tokens.Link | Tokens.Image, 'href' | 'title'>>;
151
- export type TokensList = Token[] & {
152
- links: Links;
153
- };
1
+ // Generated by dts-bundle-generator v8.0.1
2
+
3
+ export type Token = (Tokens.Space | Tokens.Code | Tokens.Heading | Tokens.Table | Tokens.Hr | Tokens.Blockquote | Tokens.List | Tokens.ListItem | Tokens.Paragraph | Tokens.HTML | Tokens.Text | Tokens.Def | Tokens.Escape | Tokens.Tag | Tokens.Image | Tokens.Link | Tokens.Strong | Tokens.Em | Tokens.Codespan | Tokens.Br | Tokens.Del | Tokens.Generic);
4
+ export declare namespace Tokens {
5
+ interface Space {
6
+ type: "space";
7
+ raw: string;
8
+ }
9
+ interface Code {
10
+ type: "code";
11
+ raw: string;
12
+ codeBlockStyle?: "indented" | undefined;
13
+ lang?: string | undefined;
14
+ text: string;
15
+ escaped?: boolean;
16
+ }
17
+ interface Heading {
18
+ type: "heading";
19
+ raw: string;
20
+ depth: number;
21
+ text: string;
22
+ tokens: Token[];
23
+ }
24
+ interface Table {
25
+ type: "table";
26
+ raw: string;
27
+ align: Array<"center" | "left" | "right" | null>;
28
+ header: TableCell[];
29
+ rows: TableCell[][];
30
+ }
31
+ interface TableCell {
32
+ text: string;
33
+ tokens: Token[];
34
+ }
35
+ interface Hr {
36
+ type: "hr";
37
+ raw: string;
38
+ }
39
+ interface Blockquote {
40
+ type: "blockquote";
41
+ raw: string;
42
+ text: string;
43
+ tokens: Token[];
44
+ }
45
+ interface List {
46
+ type: "list";
47
+ raw: string;
48
+ ordered: boolean;
49
+ start: number | "";
50
+ loose: boolean;
51
+ items: ListItem[];
52
+ }
53
+ interface ListItem {
54
+ type: "list_item";
55
+ raw: string;
56
+ task: boolean;
57
+ checked?: boolean | undefined;
58
+ loose: boolean;
59
+ text: string;
60
+ tokens: Token[];
61
+ }
62
+ interface Paragraph {
63
+ type: "paragraph";
64
+ raw: string;
65
+ pre?: boolean | undefined;
66
+ text: string;
67
+ tokens: Token[];
68
+ }
69
+ interface HTML {
70
+ type: "html";
71
+ raw: string;
72
+ pre: boolean;
73
+ text: string;
74
+ block: boolean;
75
+ }
76
+ interface Text {
77
+ type: "text";
78
+ raw: string;
79
+ text: string;
80
+ tokens?: Token[];
81
+ }
82
+ interface Def {
83
+ type: "def";
84
+ raw: string;
85
+ tag: string;
86
+ href: string;
87
+ title: string;
88
+ }
89
+ interface Escape {
90
+ type: "escape";
91
+ raw: string;
92
+ text: string;
93
+ }
94
+ interface Tag {
95
+ type: "text" | "html";
96
+ raw: string;
97
+ inLink: boolean;
98
+ inRawBlock: boolean;
99
+ text: string;
100
+ block: boolean;
101
+ }
102
+ interface Link {
103
+ type: "link";
104
+ raw: string;
105
+ href: string;
106
+ title?: string | null;
107
+ text: string;
108
+ tokens: Token[];
109
+ }
110
+ interface Image {
111
+ type: "image";
112
+ raw: string;
113
+ href: string;
114
+ title: string | null;
115
+ text: string;
116
+ }
117
+ interface Strong {
118
+ type: "strong";
119
+ raw: string;
120
+ text: string;
121
+ tokens: Token[];
122
+ }
123
+ interface Em {
124
+ type: "em";
125
+ raw: string;
126
+ text: string;
127
+ tokens: Token[];
128
+ }
129
+ interface Codespan {
130
+ type: "codespan";
131
+ raw: string;
132
+ text: string;
133
+ }
134
+ interface Br {
135
+ type: "br";
136
+ raw: string;
137
+ }
138
+ interface Del {
139
+ type: "del";
140
+ raw: string;
141
+ text: string;
142
+ tokens: Token[];
143
+ }
144
+ interface Generic {
145
+ [index: string]: any;
146
+ type: string;
147
+ raw: string;
148
+ tokens?: Token[] | undefined;
149
+ }
154
150
  }
155
- declare module "rules" {
156
- export type Rule = RegExp | string;
157
- export interface Rules {
158
- [ruleName: string]: Pick<RegExp, 'exec'> | Rule | Rules;
159
- }
160
- type BlockRuleNames = 'newline' | 'code' | 'fences' | 'hr' | 'heading' | 'blockquote' | 'list' | 'html' | 'def' | 'lheading' | '_paragraph' | 'text' | '_label' | '_title' | 'bullet' | 'listItemStart' | '_tag' | '_comment' | 'paragraph' | 'uote';
161
- type BlockSubRuleNames = 'normal' | 'gfm' | 'pedantic';
162
- type InlineRuleNames = 'escape' | 'autolink' | 'tag' | 'link' | 'reflink' | 'nolink' | 'reflinkSearch' | 'code' | 'br' | 'text' | '_punctuation' | 'punctuation' | 'blockSkip' | 'escapedEmSt' | '_comment' | '_escapes' | '_scheme' | '_email' | '_attribute' | '_label' | '_href' | '_title' | 'strong' | '_extended_email' | '_backpedal';
163
- type InlineSubRuleNames = 'gfm' | 'emStrong' | 'normal' | 'pedantic' | 'breaks';
164
- /**
165
- * Block-Level Grammar
166
- */
167
- export const block: Record<BlockRuleNames, Rule> & Record<BlockSubRuleNames, Rules> & Rules;
168
- /**
169
- * Inline-Level Grammar
170
- */
171
- export const inline: Record<InlineRuleNames, Rule> & Record<InlineSubRuleNames, Rules> & Rules;
151
+ export type Links = Record<string, Pick<Tokens.Link | Tokens.Image, "href" | "title">>;
152
+ export type TokensList = Token[] & {
153
+ links: Links;
154
+ };
155
+ declare class _Renderer {
156
+ options: MarkedOptions;
157
+ constructor(options?: MarkedOptions);
158
+ code(code: string, infostring: string | undefined, escaped: boolean): string;
159
+ blockquote(quote: string): string;
160
+ html(html: string, block?: boolean): string;
161
+ heading(text: string, level: number, raw: string): string;
162
+ hr(): string;
163
+ list(body: string, ordered: boolean, start: number | ""): string;
164
+ listitem(text: string, task: boolean, checked: boolean): string;
165
+ checkbox(checked: boolean): string;
166
+ paragraph(text: string): string;
167
+ table(header: string, body: string): string;
168
+ tablerow(content: string): string;
169
+ tablecell(content: string, flags: {
170
+ header: boolean;
171
+ align: "center" | "left" | "right" | null;
172
+ }): string;
173
+ /**
174
+ * span level renderer
175
+ */
176
+ strong(text: string): string;
177
+ em(text: string): string;
178
+ codespan(text: string): string;
179
+ br(): string;
180
+ del(text: string): string;
181
+ link(href: string, title: string | null | undefined, text: string): string;
182
+ image(href: string, title: string | null, text: string): string;
183
+ text(text: string): string;
172
184
  }
173
- declare module "helpers" {
174
- import type { Rule } from "rules";
175
- export function escape(html: string, encode?: boolean): string;
176
- export function unescape(html: string): string;
177
- export function edit(regex: Rule, opt?: string): {
178
- replace: (name: string | RegExp, val: string | RegExp) => any;
179
- getRegex: () => RegExp;
180
- };
181
- export function cleanUrl(href: string): string | null;
182
- export const noopTest: {
183
- exec: () => null;
184
- };
185
- export function splitCells(tableRow: string, count?: number): string[];
186
- /**
187
- * Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
188
- * /c*$/ is vulnerable to REDOS.
189
- *
190
- * @param str
191
- * @param c
192
- * @param invert Remove suffix of non-c chars instead. Default falsey.
193
- */
194
- export function rtrim(str: string, c: string, invert?: boolean): string;
195
- export function findClosingBracket(str: string, b: string): number;
185
+ declare class _TextRenderer {
186
+ strong(text: string): string;
187
+ em(text: string): string;
188
+ codespan(text: string): string;
189
+ del(text: string): string;
190
+ html(text: string): string;
191
+ text(text: string): string;
192
+ link(href: string, title: string | null | undefined, text: string): string;
193
+ image(href: string, title: string | null, text: string): string;
194
+ br(): string;
196
195
  }
197
- declare module "Renderer" {
198
- import type { MarkedOptions } from "MarkedOptions";
199
- /**
200
- * Renderer
201
- */
202
- export class _Renderer {
203
- options: MarkedOptions;
204
- constructor(options?: MarkedOptions);
205
- code(code: string, infostring: string | undefined, escaped: boolean): string;
206
- blockquote(quote: string): string;
207
- html(html: string, block?: boolean): string;
208
- heading(text: string, level: number, raw: string): string;
209
- hr(): string;
210
- list(body: string, ordered: boolean, start: number | ''): string;
211
- listitem(text: string, task: boolean, checked: boolean): string;
212
- checkbox(checked: boolean): string;
213
- paragraph(text: string): string;
214
- table(header: string, body: string): string;
215
- tablerow(content: string): string;
216
- tablecell(content: string, flags: {
217
- header: boolean;
218
- align: 'center' | 'left' | 'right' | null;
219
- }): string;
220
- /**
221
- * span level renderer
222
- */
223
- strong(text: string): string;
224
- em(text: string): string;
225
- codespan(text: string): string;
226
- br(): string;
227
- del(text: string): string;
228
- link(href: string, title: string | null | undefined, text: string): string;
229
- image(href: string, title: string | null, text: string): string;
230
- text(text: string): string;
231
- }
196
+ declare class _Parser {
197
+ options: MarkedOptions;
198
+ renderer: _Renderer;
199
+ textRenderer: _TextRenderer;
200
+ constructor(options?: MarkedOptions);
201
+ /**
202
+ * Static Parse Method
203
+ */
204
+ static parse(tokens: Token[], options?: MarkedOptions): string;
205
+ /**
206
+ * Static Parse Inline Method
207
+ */
208
+ static parseInline(tokens: Token[], options?: MarkedOptions): string;
209
+ /**
210
+ * Parse Loop
211
+ */
212
+ parse(tokens: Token[], top?: boolean): string;
213
+ /**
214
+ * Parse Inline Tokens
215
+ */
216
+ parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
232
217
  }
233
- declare module "TextRenderer" {
234
- /**
235
- * TextRenderer
236
- * returns only the textual part of the token
237
- */
238
- export class _TextRenderer {
239
- strong(text: string): string;
240
- em(text: string): string;
241
- codespan(text: string): string;
242
- del(text: string): string;
243
- html(text: string): string;
244
- text(text: string): string;
245
- link(href: string, title: string | null | undefined, text: string): string;
246
- image(href: string, title: string | null, text: string): string;
247
- br(): string;
248
- }
218
+ declare class _Tokenizer {
219
+ options: MarkedOptions;
220
+ rules: any;
221
+ lexer: _Lexer;
222
+ constructor(options?: MarkedOptions);
223
+ space(src: string): Tokens.Space | undefined;
224
+ code(src: string): Tokens.Code | undefined;
225
+ fences(src: string): Tokens.Code | undefined;
226
+ heading(src: string): Tokens.Heading | undefined;
227
+ hr(src: string): Tokens.Hr | undefined;
228
+ blockquote(src: string): Tokens.Blockquote | undefined;
229
+ list(src: string): Tokens.List | undefined;
230
+ html(src: string): Tokens.HTML | undefined;
231
+ def(src: string): Tokens.Def | undefined;
232
+ table(src: string): Tokens.Table | undefined;
233
+ lheading(src: string): Tokens.Heading | undefined;
234
+ paragraph(src: string): Tokens.Paragraph | undefined;
235
+ text(src: string): Tokens.Text | undefined;
236
+ escape(src: string): Tokens.Escape | undefined;
237
+ tag(src: string): Tokens.Tag | undefined;
238
+ link(src: string): Tokens.Link | Tokens.Image | undefined;
239
+ reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Tokens.Text | undefined;
240
+ emStrong(src: string, maskedSrc: string, prevChar?: string): Tokens.Em | Tokens.Strong | undefined;
241
+ codespan(src: string): Tokens.Codespan | undefined;
242
+ br(src: string): Tokens.Br | undefined;
243
+ del(src: string): Tokens.Del | undefined;
244
+ autolink(src: string): Tokens.Link | undefined;
245
+ url(src: string): Tokens.Link | undefined;
246
+ inlineText(src: string): Tokens.Text | undefined;
249
247
  }
250
- declare module "Parser" {
251
- import { _Renderer } from "Renderer";
252
- import { _TextRenderer } from "TextRenderer";
253
- import type { Token } from "Tokens";
254
- import type { MarkedOptions } from "MarkedOptions";
255
- /**
256
- * Parsing & Compiling
257
- */
258
- export class _Parser {
259
- options: MarkedOptions;
260
- renderer: _Renderer;
261
- textRenderer: _TextRenderer;
262
- constructor(options?: MarkedOptions);
263
- /**
264
- * Static Parse Method
265
- */
266
- static parse(tokens: Token[], options?: MarkedOptions): string;
267
- /**
268
- * Static Parse Inline Method
269
- */
270
- static parseInline(tokens: Token[], options?: MarkedOptions): string;
271
- /**
272
- * Parse Loop
273
- */
274
- parse(tokens: Token[], top?: boolean): string;
275
- /**
276
- * Parse Inline Tokens
277
- */
278
- parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
279
- }
248
+ export interface TokenizerThis {
249
+ lexer: _Lexer;
280
250
  }
281
- declare module "Tokenizer" {
282
- import type { _Lexer } from "Lexer";
283
- import type { Links, Tokens } from "Tokens";
284
- import type { MarkedOptions } from "MarkedOptions";
285
- /**
286
- * Tokenizer
287
- */
288
- export class _Tokenizer {
289
- options: MarkedOptions;
290
- rules: any;
291
- lexer: _Lexer;
292
- constructor(options?: MarkedOptions);
293
- space(src: string): Tokens.Space | undefined;
294
- code(src: string): Tokens.Code | undefined;
295
- fences(src: string): Tokens.Code | undefined;
296
- heading(src: string): Tokens.Heading | undefined;
297
- hr(src: string): Tokens.Hr | undefined;
298
- blockquote(src: string): Tokens.Blockquote | undefined;
299
- list(src: string): Tokens.List | undefined;
300
- html(src: string): Tokens.HTML | undefined;
301
- def(src: string): Tokens.Def | undefined;
302
- table(src: string): Tokens.Table | undefined;
303
- lheading(src: string): Tokens.Heading | undefined;
304
- paragraph(src: string): Tokens.Paragraph | undefined;
305
- text(src: string): Tokens.Text | undefined;
306
- escape(src: string): Tokens.Escape | undefined;
307
- tag(src: string): Tokens.Tag | undefined;
308
- link(src: string): Tokens.Link | Tokens.Image | undefined;
309
- reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Tokens.Text | undefined;
310
- emStrong(src: string, maskedSrc: string, prevChar?: string): Tokens.Em | Tokens.Strong | undefined;
311
- codespan(src: string): Tokens.Codespan | undefined;
312
- br(src: string): Tokens.Br | undefined;
313
- del(src: string): Tokens.Del | undefined;
314
- autolink(src: string): Tokens.Link | undefined;
315
- url(src: string): Tokens.Link | undefined;
316
- inlineText(src: string): Tokens.Text | undefined;
317
- }
251
+ export type TokenizerExtensionFunction = (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | undefined;
252
+ export type TokenizerStartFunction = (this: TokenizerThis, src: string) => number | void;
253
+ export interface TokenizerExtension {
254
+ name: string;
255
+ level: "block" | "inline";
256
+ start?: TokenizerStartFunction | undefined;
257
+ tokenizer: TokenizerExtensionFunction;
258
+ childTokens?: string[] | undefined;
318
259
  }
319
- declare module "Lexer" {
320
- import type { Token, TokensList } from "Tokens";
321
- import type { MarkedOptions } from "MarkedOptions";
322
- import type { Rules } from "rules";
323
- /**
324
- * Block Lexer
325
- */
326
- export class _Lexer {
327
- tokens: TokensList;
328
- options: MarkedOptions;
329
- state: {
330
- inLink: boolean;
331
- inRawBlock: boolean;
332
- top: boolean;
333
- };
334
- private tokenizer;
335
- private inlineQueue;
336
- constructor(options?: MarkedOptions);
337
- /**
338
- * Expose Rules
339
- */
340
- static get rules(): Rules;
341
- /**
342
- * Static Lex Method
343
- */
344
- static lex(src: string, options?: MarkedOptions): TokensList;
345
- /**
346
- * Static Lex Inline Method
347
- */
348
- static lexInline(src: string, options?: MarkedOptions): Token[];
349
- /**
350
- * Preprocessing
351
- */
352
- lex(src: string): TokensList;
353
- /**
354
- * Lexing
355
- */
356
- blockTokens(src: string, tokens?: Token[]): Token[];
357
- blockTokens(src: string, tokens?: TokensList): TokensList;
358
- inline(src: string, tokens?: Token[]): Token[];
359
- /**
360
- * Lexing/Compiling
361
- */
362
- inlineTokens(src: string, tokens?: Token[]): Token[];
363
- }
260
+ export interface RendererThis {
261
+ parser: _Parser;
364
262
  }
365
- declare module "MarkedOptions" {
366
- import type { Token, Tokens, TokensList } from "Tokens";
367
- import type { _Parser } from "Parser";
368
- import type { _Lexer } from "Lexer";
369
- import type { _Renderer } from "Renderer";
370
- import type { _Tokenizer } from "Tokenizer";
371
- export interface TokenizerThis {
372
- lexer: _Lexer;
373
- }
374
- export type TokenizerExtensionFunction = (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | undefined;
375
- export type TokenizerStartFunction = (this: TokenizerThis, src: string) => number | void;
376
- export interface TokenizerExtension {
377
- name: string;
378
- level: 'block' | 'inline';
379
- start?: TokenizerStartFunction | undefined;
380
- tokenizer: TokenizerExtensionFunction;
381
- childTokens?: string[] | undefined;
382
- }
383
- export interface RendererThis {
384
- parser: _Parser;
385
- }
386
- export type RendererExtensionFunction = (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
387
- export interface RendererExtension {
388
- name: string;
389
- renderer: RendererExtensionFunction;
390
- }
391
- export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
392
- type RendererApi = Omit<_Renderer, 'constructor' | 'options'>;
393
- type RendererObject = {
394
- [K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false;
395
- };
396
- type TokenizerApi = Omit<_Tokenizer, 'constructor' | 'options' | 'rules' | 'lexer'>;
397
- type TokenizerObject = {
398
- [K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false;
399
- };
400
- export interface MarkedExtension {
401
- /**
402
- * True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
403
- */
404
- async?: boolean;
405
- /**
406
- * Enable GFM line breaks. This option requires the gfm option to be true.
407
- */
408
- breaks?: boolean | undefined;
409
- /**
410
- * Add tokenizers and renderers to marked
411
- */
412
- extensions?: TokenizerAndRendererExtension[] | undefined | null;
413
- /**
414
- * Enable GitHub flavored markdown.
415
- */
416
- gfm?: boolean | undefined;
417
- /**
418
- * Hooks are methods that hook into some part of marked.
419
- * preprocess is called to process markdown before sending it to marked.
420
- * postprocess is called to process html after marked has finished parsing.
421
- */
422
- hooks?: {
423
- preprocess: (markdown: string) => string | Promise<string>;
424
- postprocess: (html: string) => string | Promise<string>;
425
- options?: MarkedOptions;
426
- } | null;
427
- /**
428
- * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
429
- */
430
- pedantic?: boolean | undefined;
431
- /**
432
- * Type: object Default: new Renderer()
433
- *
434
- * An object containing functions to render tokens to HTML.
435
- */
436
- renderer?: RendererObject | undefined | null;
437
- /**
438
- * Shows an HTML error message when rendering fails.
439
- */
440
- silent?: boolean | undefined;
441
- /**
442
- * The tokenizer defines how to turn markdown text into tokens.
443
- */
444
- tokenizer?: TokenizerObject | undefined | null;
445
- /**
446
- * The walkTokens function gets called with every token.
447
- * Child tokens are called before moving on to sibling tokens.
448
- * Each token is passed by reference so updates are persisted when passed to the parser.
449
- * The return value of the function is ignored.
450
- */
451
- walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
452
- }
453
- export interface MarkedOptions extends Omit<MarkedExtension, 'renderer' | 'tokenizer' | 'extensions' | 'walkTokens'> {
454
- /**
455
- * Type: object Default: new Renderer()
456
- *
457
- * An object containing functions to render tokens to HTML.
458
- */
459
- renderer?: _Renderer | undefined | null;
460
- /**
461
- * The tokenizer defines how to turn markdown text into tokens.
462
- */
463
- tokenizer?: _Tokenizer | undefined | null;
464
- /**
465
- * Custom extensions
466
- */
467
- extensions?: null | {
468
- renderers: {
469
- [name: string]: RendererExtensionFunction;
470
- };
471
- childTokens: {
472
- [name: string]: string[];
473
- };
474
- inline?: TokenizerExtensionFunction[];
475
- block?: TokenizerExtensionFunction[];
476
- startInline?: TokenizerStartFunction[];
477
- startBlock?: TokenizerStartFunction[];
478
- };
479
- /**
480
- * walkTokens function returns array of values for Promise.all
481
- */
482
- walkTokens?: null | ((token: Token) => void | Promise<void> | (void | Promise<void>)[]);
483
- }
263
+ export type RendererExtensionFunction = (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
264
+ export interface RendererExtension {
265
+ name: string;
266
+ renderer: RendererExtensionFunction;
484
267
  }
485
- declare module "defaults" {
486
- import type { MarkedOptions } from "MarkedOptions";
487
- /**
488
- * Gets the original marked default options.
489
- */
490
- export function _getDefaults(): MarkedOptions;
491
- export let _defaults: MarkedOptions;
492
- export function changeDefaults(newDefaults: MarkedOptions): void;
268
+ export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
269
+ export type RendererApi = Omit<_Renderer, "constructor" | "options">;
270
+ export type RendererObject = {
271
+ [K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false;
272
+ };
273
+ export type TokenizerApi = Omit<_Tokenizer, "constructor" | "options" | "rules" | "lexer">;
274
+ export type TokenizerObject = {
275
+ [K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false;
276
+ };
277
+ export interface MarkedExtension {
278
+ /**
279
+ * True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
280
+ */
281
+ async?: boolean;
282
+ /**
283
+ * Enable GFM line breaks. This option requires the gfm option to be true.
284
+ */
285
+ breaks?: boolean | undefined;
286
+ /**
287
+ * Add tokenizers and renderers to marked
288
+ */
289
+ extensions?: TokenizerAndRendererExtension[] | undefined | null;
290
+ /**
291
+ * Enable GitHub flavored markdown.
292
+ */
293
+ gfm?: boolean | undefined;
294
+ /**
295
+ * Hooks are methods that hook into some part of marked.
296
+ * preprocess is called to process markdown before sending it to marked.
297
+ * postprocess is called to process html after marked has finished parsing.
298
+ */
299
+ hooks?: {
300
+ preprocess: (markdown: string) => string | Promise<string>;
301
+ postprocess: (html: string) => string | Promise<string>;
302
+ options?: MarkedOptions;
303
+ } | null;
304
+ /**
305
+ * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
306
+ */
307
+ pedantic?: boolean | undefined;
308
+ /**
309
+ * Type: object Default: new Renderer()
310
+ *
311
+ * An object containing functions to render tokens to HTML.
312
+ */
313
+ renderer?: RendererObject | undefined | null;
314
+ /**
315
+ * Shows an HTML error message when rendering fails.
316
+ */
317
+ silent?: boolean | undefined;
318
+ /**
319
+ * The tokenizer defines how to turn markdown text into tokens.
320
+ */
321
+ tokenizer?: TokenizerObject | undefined | null;
322
+ /**
323
+ * The walkTokens function gets called with every token.
324
+ * Child tokens are called before moving on to sibling tokens.
325
+ * Each token is passed by reference so updates are persisted when passed to the parser.
326
+ * The return value of the function is ignored.
327
+ */
328
+ walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
493
329
  }
494
- declare module "Hooks" {
495
- import type { MarkedOptions } from "MarkedOptions";
496
- export class _Hooks {
497
- options: MarkedOptions;
498
- constructor(options?: MarkedOptions);
499
- static passThroughHooks: Set<string>;
500
- /**
501
- * Process markdown before marked
502
- */
503
- preprocess(markdown: string): string;
504
- /**
505
- * Process HTML after marked is finished
506
- */
507
- postprocess(html: string): string;
508
- }
330
+ export interface MarkedOptions extends Omit<MarkedExtension, "renderer" | "tokenizer" | "extensions" | "walkTokens"> {
331
+ /**
332
+ * Type: object Default: new Renderer()
333
+ *
334
+ * An object containing functions to render tokens to HTML.
335
+ */
336
+ renderer?: _Renderer | undefined | null;
337
+ /**
338
+ * The tokenizer defines how to turn markdown text into tokens.
339
+ */
340
+ tokenizer?: _Tokenizer | undefined | null;
341
+ /**
342
+ * Custom extensions
343
+ */
344
+ extensions?: null | {
345
+ renderers: {
346
+ [name: string]: RendererExtensionFunction;
347
+ };
348
+ childTokens: {
349
+ [name: string]: string[];
350
+ };
351
+ inline?: TokenizerExtensionFunction[];
352
+ block?: TokenizerExtensionFunction[];
353
+ startInline?: TokenizerStartFunction[];
354
+ startBlock?: TokenizerStartFunction[];
355
+ };
356
+ /**
357
+ * walkTokens function returns array of values for Promise.all
358
+ */
359
+ walkTokens?: null | ((token: Token) => void | Promise<void> | (void | Promise<void>)[]);
509
360
  }
510
- declare module "Instance" {
511
- import { _Lexer } from "Lexer";
512
- import { _Parser } from "Parser";
513
- import { _Hooks } from "Hooks";
514
- import { _Renderer } from "Renderer";
515
- import { _Tokenizer } from "Tokenizer";
516
- import { _TextRenderer } from "TextRenderer";
517
- import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
518
- import type { Token, TokensList } from "Tokens";
519
- export type MaybePromise = void | Promise<void>;
520
- export class Marked {
521
- #private;
522
- defaults: MarkedOptions;
523
- options: (opt: MarkedOptions) => this;
524
- parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
525
- parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
526
- Parser: typeof _Parser;
527
- parser: typeof _Parser.parse;
528
- Renderer: typeof _Renderer;
529
- TextRenderer: typeof _TextRenderer;
530
- Lexer: typeof _Lexer;
531
- lexer: typeof _Lexer.lex;
532
- Tokenizer: typeof _Tokenizer;
533
- Hooks: typeof _Hooks;
534
- constructor(...args: MarkedExtension[]);
535
- /**
536
- * Run callback for every token
537
- */
538
- walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
539
- use(...args: MarkedExtension[]): this;
540
- setOptions(opt: MarkedOptions): this;
541
- }
361
+ export type Rule = RegExp | string;
362
+ export interface Rules {
363
+ [ruleName: string]: Pick<RegExp, "exec"> | Rule | Rules;
542
364
  }
543
- declare module "marked" {
544
- import { _Lexer } from "Lexer";
545
- import { _Parser } from "Parser";
546
- import { _Tokenizer } from "Tokenizer";
547
- import { _Renderer } from "Renderer";
548
- import { _TextRenderer } from "TextRenderer";
549
- import { _Hooks } from "Hooks";
550
- import { _getDefaults } from "defaults";
551
- import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
552
- import type { Token, TokensList } from "Tokens";
553
- import type { MaybePromise } from "Instance";
554
- /**
555
- * Compiles markdown to HTML asynchronously.
556
- *
557
- * @param src String of markdown source to be compiled
558
- * @param options Hash of options, having async: true
559
- * @return Promise of string of compiled HTML
560
- */
561
- export function marked(src: string, options: MarkedOptions & {
562
- async: true;
563
- }): Promise<string>;
564
- /**
565
- * Compiles markdown to HTML synchronously.
566
- *
567
- * @param src String of markdown source to be compiled
568
- * @param options Optional hash of options
569
- * @return String of compiled HTML
570
- */
571
- export function marked(src: string, options?: MarkedOptions): string;
572
- /**
573
- * Compiles markdown to HTML synchronously.
574
- *
575
- * @param src String of markdown source to be compiled
576
- * @param options Optional hash of options
577
- * @return String of compiled HTML
578
- */
579
- export namespace marked {
580
- var options: (options: MarkedOptions) => typeof marked;
581
- var setOptions: (options: MarkedOptions) => typeof marked;
582
- var getDefaults: typeof _getDefaults;
583
- var defaults: MarkedOptions;
584
- var use: (...args: MarkedExtension[]) => typeof marked;
585
- var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
586
- var parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
587
- var Parser: typeof _Parser;
588
- var parser: typeof _Parser.parse;
589
- var Renderer: typeof _Renderer;
590
- var TextRenderer: typeof _TextRenderer;
591
- var Lexer: typeof _Lexer;
592
- var lexer: typeof _Lexer.lex;
593
- var Tokenizer: typeof _Tokenizer;
594
- var Hooks: typeof _Hooks;
595
- var parse: typeof marked;
596
- }
597
- export const options: (options: MarkedOptions) => typeof marked;
598
- export const setOptions: (options: MarkedOptions) => typeof marked;
599
- export const use: (...args: MarkedExtension[]) => typeof marked;
600
- export const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
601
- export const parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
602
- export const parse: typeof marked;
603
- export const parser: typeof _Parser.parse;
604
- export const lexer: typeof _Lexer.lex;
605
- export { _defaults as defaults, _getDefaults as getDefaults } from "defaults";
606
- export { _Lexer as Lexer } from "Lexer";
607
- export { _Parser as Parser } from "Parser";
608
- export { _Tokenizer as Tokenizer } from "Tokenizer";
609
- export { _Renderer as Renderer } from "Renderer";
610
- export { _TextRenderer as TextRenderer } from "TextRenderer";
611
- export { _Hooks as Hooks } from "Hooks";
612
- export { Marked } from "Instance";
613
- export type * from "MarkedOptions";
614
- export type * from "rules";
615
- export type * from "Tokens";
365
+ export type BlockRuleNames = "newline" | "code" | "fences" | "hr" | "heading" | "blockquote" | "list" | "html" | "def" | "lheading" | "_paragraph" | "text" | "_label" | "_title" | "bullet" | "listItemStart" | "_tag" | "_comment" | "paragraph" | "uote";
366
+ export type BlockSubRuleNames = "normal" | "gfm" | "pedantic";
367
+ export type InlineRuleNames = "escape" | "autolink" | "tag" | "link" | "reflink" | "nolink" | "reflinkSearch" | "code" | "br" | "text" | "_punctuation" | "punctuation" | "blockSkip" | "escapedEmSt" | "_comment" | "_escapes" | "_scheme" | "_email" | "_attribute" | "_label" | "_href" | "_title" | "strong" | "_extended_email" | "_backpedal";
368
+ export type InlineSubRuleNames = "gfm" | "emStrong" | "normal" | "pedantic" | "breaks";
369
+ /**
370
+ * Block-Level Grammar
371
+ */
372
+ export declare const block: Record<BlockRuleNames, Rule> & Record<BlockSubRuleNames, Rules> & Rules;
373
+ /**
374
+ * Inline-Level Grammar
375
+ */
376
+ export declare const inline: Record<InlineRuleNames, Rule> & Record<InlineSubRuleNames, Rules> & Rules;
377
+ declare class _Lexer {
378
+ tokens: TokensList;
379
+ options: MarkedOptions;
380
+ state: {
381
+ inLink: boolean;
382
+ inRawBlock: boolean;
383
+ top: boolean;
384
+ };
385
+ private tokenizer;
386
+ private inlineQueue;
387
+ constructor(options?: MarkedOptions);
388
+ /**
389
+ * Expose Rules
390
+ */
391
+ static get rules(): Rules;
392
+ /**
393
+ * Static Lex Method
394
+ */
395
+ static lex(src: string, options?: MarkedOptions): TokensList;
396
+ /**
397
+ * Static Lex Inline Method
398
+ */
399
+ static lexInline(src: string, options?: MarkedOptions): Token[];
400
+ /**
401
+ * Preprocessing
402
+ */
403
+ lex(src: string): TokensList;
404
+ /**
405
+ * Lexing
406
+ */
407
+ blockTokens(src: string, tokens?: Token[]): Token[];
408
+ blockTokens(src: string, tokens?: TokensList): TokensList;
409
+ inline(src: string, tokens?: Token[]): Token[];
410
+ /**
411
+ * Lexing/Compiling
412
+ */
413
+ inlineTokens(src: string, tokens?: Token[]): Token[];
616
414
  }
415
+ declare class _Hooks {
416
+ options: MarkedOptions;
417
+ constructor(options?: MarkedOptions);
418
+ static passThroughHooks: Set<string>;
419
+ /**
420
+ * Process markdown before marked
421
+ */
422
+ preprocess(markdown: string): string;
423
+ /**
424
+ * Process HTML after marked is finished
425
+ */
426
+ postprocess(html: string): string;
427
+ }
428
+ declare function _getDefaults(): MarkedOptions;
429
+ declare let _defaults: MarkedOptions;
430
+ export type MaybePromise = void | Promise<void>;
431
+ export declare class Marked {
432
+ #private;
433
+ defaults: MarkedOptions;
434
+ options: (opt: MarkedOptions) => this;
435
+ parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
436
+ parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
437
+ Parser: typeof _Parser;
438
+ parser: typeof _Parser.parse;
439
+ Renderer: typeof _Renderer;
440
+ TextRenderer: typeof _TextRenderer;
441
+ Lexer: typeof _Lexer;
442
+ lexer: typeof _Lexer.lex;
443
+ Tokenizer: typeof _Tokenizer;
444
+ Hooks: typeof _Hooks;
445
+ constructor(...args: MarkedExtension[]);
446
+ /**
447
+ * Run callback for every token
448
+ */
449
+ walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
450
+ use(...args: MarkedExtension[]): this;
451
+ setOptions(opt: MarkedOptions): this;
452
+ }
453
+ /**
454
+ * Compiles markdown to HTML asynchronously.
455
+ *
456
+ * @param src String of markdown source to be compiled
457
+ * @param options Hash of options, having async: true
458
+ * @return Promise of string of compiled HTML
459
+ */
460
+ export declare function marked(src: string, options: MarkedOptions & {
461
+ async: true;
462
+ }): Promise<string>;
463
+ /**
464
+ * Compiles markdown to HTML synchronously.
465
+ *
466
+ * @param src String of markdown source to be compiled
467
+ * @param options Optional hash of options
468
+ * @return String of compiled HTML
469
+ */
470
+ export declare function marked(src: string, options?: MarkedOptions): string;
471
+ export declare namespace marked {
472
+ var options: (options: MarkedOptions) => typeof marked;
473
+ var setOptions: (options: MarkedOptions) => typeof marked;
474
+ var getDefaults: typeof _getDefaults;
475
+ var defaults: MarkedOptions;
476
+ var use: (...args: MarkedExtension[]) => typeof marked;
477
+ var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
478
+ var parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
479
+ var Parser: typeof _Parser;
480
+ var parser: typeof _Parser.parse;
481
+ var Renderer: typeof _Renderer;
482
+ var TextRenderer: typeof _TextRenderer;
483
+ var Lexer: typeof _Lexer;
484
+ var lexer: typeof _Lexer.lex;
485
+ var Tokenizer: typeof _Tokenizer;
486
+ var Hooks: typeof _Hooks;
487
+ var parse: typeof marked;
488
+ }
489
+ export declare const options: (options: MarkedOptions) => typeof marked;
490
+ export declare const setOptions: (options: MarkedOptions) => typeof marked;
491
+ export declare const use: (...args: MarkedExtension[]) => typeof marked;
492
+ export declare const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
493
+ export declare const parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
494
+ export declare const parse: typeof marked;
495
+ export declare const parser: typeof _Parser.parse;
496
+ export declare const lexer: typeof _Lexer.lex;
497
+
498
+ export {
499
+ _Hooks as Hooks,
500
+ _Lexer as Lexer,
501
+ _Parser as Parser,
502
+ _Renderer as Renderer,
503
+ _TextRenderer as TextRenderer,
504
+ _Tokenizer as Tokenizer,
505
+ _defaults as defaults,
506
+ _getDefaults as getDefaults,
507
+ };
508
+
509
+ export {};