marked 7.0.4 → 8.0.0
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/bin/main.js +270 -0
- package/bin/marked.js +2 -204
- package/lib/marked.cjs +31 -314
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.d.ts +146 -255
- package/lib/marked.esm.js +32 -314
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +31 -314
- package/lib/marked.umd.js.map +1 -1
- package/man/marked.1 +5 -18
- package/man/marked.1.txt +2 -15
- package/marked.min.js +6 -7
- package/package.json +11 -11
package/lib/marked.d.ts
CHANGED
|
@@ -152,44 +152,6 @@ declare module "Tokens" {
|
|
|
152
152
|
links: Links;
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
declare module "Tokenizer" {
|
|
156
|
-
import type { _Lexer } from "Lexer";
|
|
157
|
-
import type { Links, Tokens } from "Tokens";
|
|
158
|
-
import type { MarkedOptions } from "MarkedOptions";
|
|
159
|
-
/**
|
|
160
|
-
* Tokenizer
|
|
161
|
-
*/
|
|
162
|
-
export class _Tokenizer {
|
|
163
|
-
options: MarkedOptions;
|
|
164
|
-
rules: any;
|
|
165
|
-
lexer: _Lexer;
|
|
166
|
-
constructor(options?: MarkedOptions);
|
|
167
|
-
space(src: string): Tokens.Space | undefined;
|
|
168
|
-
code(src: string): Tokens.Code | undefined;
|
|
169
|
-
fences(src: string): Tokens.Code | undefined;
|
|
170
|
-
heading(src: string): Tokens.Heading | undefined;
|
|
171
|
-
hr(src: string): Tokens.Hr | undefined;
|
|
172
|
-
blockquote(src: string): Tokens.Blockquote | undefined;
|
|
173
|
-
list(src: string): Tokens.List | undefined;
|
|
174
|
-
html(src: string): Tokens.HTML | Tokens.Paragraph | undefined;
|
|
175
|
-
def(src: string): Tokens.Def | undefined;
|
|
176
|
-
table(src: string): Tokens.Table | undefined;
|
|
177
|
-
lheading(src: string): Tokens.Heading | undefined;
|
|
178
|
-
paragraph(src: string): Tokens.Paragraph | undefined;
|
|
179
|
-
text(src: string): Tokens.Text | undefined;
|
|
180
|
-
escape(src: string): Tokens.Escape | undefined;
|
|
181
|
-
tag(src: string): Tokens.Tag | undefined;
|
|
182
|
-
link(src: string): Tokens.Link | Tokens.Image | undefined;
|
|
183
|
-
reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Tokens.Text | undefined;
|
|
184
|
-
emStrong(src: string, maskedSrc: string, prevChar?: string): Tokens.Em | Tokens.Strong | undefined;
|
|
185
|
-
codespan(src: string): Tokens.Codespan | undefined;
|
|
186
|
-
br(src: string): Tokens.Br | undefined;
|
|
187
|
-
del(src: string): Tokens.Del | undefined;
|
|
188
|
-
autolink(src: string, mangle: (cap: string) => string): Tokens.Link | undefined;
|
|
189
|
-
url(src: string, mangle: (cap: string) => string): Tokens.Link | undefined;
|
|
190
|
-
inlineText(src: string, smartypants: (cap: string) => string): Tokens.Text | undefined;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
155
|
declare module "rules" {
|
|
194
156
|
export type Rule = RegExp | string;
|
|
195
157
|
export interface Rules {
|
|
@@ -208,128 +170,7 @@ declare module "rules" {
|
|
|
208
170
|
*/
|
|
209
171
|
export const inline: Record<InlineRuleNames, Rule> & Record<InlineSubRuleNames, Rules> & Rules;
|
|
210
172
|
}
|
|
211
|
-
declare module "Lexer" {
|
|
212
|
-
import type { Token, TokensList } from "Tokens";
|
|
213
|
-
import type { MarkedOptions } from "MarkedOptions";
|
|
214
|
-
import type { Rules } from "rules";
|
|
215
|
-
/**
|
|
216
|
-
* Block Lexer
|
|
217
|
-
*/
|
|
218
|
-
export class _Lexer {
|
|
219
|
-
tokens: TokensList;
|
|
220
|
-
options: MarkedOptions;
|
|
221
|
-
state: {
|
|
222
|
-
inLink: boolean;
|
|
223
|
-
inRawBlock: boolean;
|
|
224
|
-
top: boolean;
|
|
225
|
-
};
|
|
226
|
-
private tokenizer;
|
|
227
|
-
private inlineQueue;
|
|
228
|
-
constructor(options?: MarkedOptions);
|
|
229
|
-
/**
|
|
230
|
-
* Expose Rules
|
|
231
|
-
*/
|
|
232
|
-
static get rules(): Rules;
|
|
233
|
-
/**
|
|
234
|
-
* Static Lex Method
|
|
235
|
-
*/
|
|
236
|
-
static lex(src: string, options?: MarkedOptions): TokensList;
|
|
237
|
-
/**
|
|
238
|
-
* Static Lex Inline Method
|
|
239
|
-
*/
|
|
240
|
-
static lexInline(src: string, options?: MarkedOptions): Token[];
|
|
241
|
-
/**
|
|
242
|
-
* Preprocessing
|
|
243
|
-
*/
|
|
244
|
-
lex(src: string): TokensList;
|
|
245
|
-
/**
|
|
246
|
-
* Lexing
|
|
247
|
-
*/
|
|
248
|
-
blockTokens(src: string, tokens?: Token[]): Token[];
|
|
249
|
-
blockTokens(src: string, tokens?: TokensList): TokensList;
|
|
250
|
-
inline(src: string, tokens?: Token[]): Token[];
|
|
251
|
-
/**
|
|
252
|
-
* Lexing/Compiling
|
|
253
|
-
*/
|
|
254
|
-
inlineTokens(src: string, tokens?: Token[]): Token[];
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
declare module "TextRenderer" {
|
|
258
|
-
/**
|
|
259
|
-
* TextRenderer
|
|
260
|
-
* returns only the textual part of the token
|
|
261
|
-
*/
|
|
262
|
-
export class _TextRenderer {
|
|
263
|
-
strong(text: string): string;
|
|
264
|
-
em(text: string): string;
|
|
265
|
-
codespan(text: string): string;
|
|
266
|
-
del(text: string): string;
|
|
267
|
-
html(text: string): string;
|
|
268
|
-
text(text: string): string;
|
|
269
|
-
link(href: string, title: string | null | undefined, text: string): string;
|
|
270
|
-
image(href: string, title: string | null, text: string): string;
|
|
271
|
-
br(): string;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
declare module "Slugger" {
|
|
275
|
-
import type { SluggerOptions } from "MarkedOptions";
|
|
276
|
-
/**
|
|
277
|
-
* Slugger generates header id
|
|
278
|
-
*/
|
|
279
|
-
export class _Slugger {
|
|
280
|
-
seen: {
|
|
281
|
-
[slugValue: string]: number;
|
|
282
|
-
};
|
|
283
|
-
constructor();
|
|
284
|
-
serialize(value: string): string;
|
|
285
|
-
/**
|
|
286
|
-
* Finds the next safe (unique) slug to use
|
|
287
|
-
*/
|
|
288
|
-
getNextSafeSlug(originalSlug: string, isDryRun: boolean | undefined): string;
|
|
289
|
-
/**
|
|
290
|
-
* Convert string to unique id
|
|
291
|
-
*/
|
|
292
|
-
slug(value: string, options?: SluggerOptions): string;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
declare module "Instance" {
|
|
296
|
-
import { _Lexer } from "Lexer";
|
|
297
|
-
import { _Parser } from "Parser";
|
|
298
|
-
import { _Hooks } from "Hooks";
|
|
299
|
-
import { _Renderer } from "Renderer";
|
|
300
|
-
import { _Tokenizer } from "Tokenizer";
|
|
301
|
-
import { _TextRenderer } from "TextRenderer";
|
|
302
|
-
import { _Slugger } from "Slugger";
|
|
303
|
-
import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
|
|
304
|
-
import type { Token, TokensList } from "Tokens";
|
|
305
|
-
export type ResultCallback = (error: Error | null, parseResult?: string) => undefined | void;
|
|
306
|
-
export class Marked {
|
|
307
|
-
#private;
|
|
308
|
-
defaults: MarkedOptions;
|
|
309
|
-
options: (opt: MarkedOptions) => this;
|
|
310
|
-
parse: (src: string, optOrCallback?: MarkedOptions | ResultCallback | undefined | null, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
|
311
|
-
parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | undefined | null, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
|
312
|
-
Parser: typeof _Parser;
|
|
313
|
-
parser: typeof _Parser.parse;
|
|
314
|
-
Renderer: typeof _Renderer;
|
|
315
|
-
TextRenderer: typeof _TextRenderer;
|
|
316
|
-
Lexer: typeof _Lexer;
|
|
317
|
-
lexer: typeof _Lexer.lex;
|
|
318
|
-
Tokenizer: typeof _Tokenizer;
|
|
319
|
-
Slugger: typeof _Slugger;
|
|
320
|
-
Hooks: typeof _Hooks;
|
|
321
|
-
constructor(...args: MarkedExtension[]);
|
|
322
|
-
/**
|
|
323
|
-
* Run callback for every token
|
|
324
|
-
*/
|
|
325
|
-
walkTokens<T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]): T[];
|
|
326
|
-
use(...args: MarkedExtension[]): this;
|
|
327
|
-
setOptions(opt: MarkedOptions): this;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
173
|
declare module "helpers" {
|
|
331
|
-
import type { MarkedOptions } from "MarkedOptions";
|
|
332
|
-
import type { ResultCallback } from "Instance";
|
|
333
174
|
import type { Rule } from "rules";
|
|
334
175
|
export function escape(html: string, encode?: boolean): string;
|
|
335
176
|
export function unescape(html: string): string;
|
|
@@ -337,8 +178,7 @@ declare module "helpers" {
|
|
|
337
178
|
replace: (name: string | RegExp, val: string | RegExp) => any;
|
|
338
179
|
getRegex: () => RegExp;
|
|
339
180
|
};
|
|
340
|
-
export function cleanUrl(
|
|
341
|
-
export function resolveUrl(base: string, href: string): string;
|
|
181
|
+
export function cleanUrl(href: string): string | null;
|
|
342
182
|
export const noopTest: {
|
|
343
183
|
exec: () => null;
|
|
344
184
|
};
|
|
@@ -353,11 +193,9 @@ declare module "helpers" {
|
|
|
353
193
|
*/
|
|
354
194
|
export function rtrim(str: string, c: string, invert?: boolean): string;
|
|
355
195
|
export function findClosingBracket(str: string, b: string): number;
|
|
356
|
-
export function checkDeprecations(opt: MarkedOptions, callback?: ResultCallback): void;
|
|
357
196
|
}
|
|
358
197
|
declare module "Renderer" {
|
|
359
198
|
import type { MarkedOptions } from "MarkedOptions";
|
|
360
|
-
import type { _Slugger } from "Slugger";
|
|
361
199
|
/**
|
|
362
200
|
* Renderer
|
|
363
201
|
*/
|
|
@@ -367,7 +205,7 @@ declare module "Renderer" {
|
|
|
367
205
|
code(code: string, infostring: string | undefined, escaped: boolean): string;
|
|
368
206
|
blockquote(quote: string): string;
|
|
369
207
|
html(html: string, block?: boolean): string;
|
|
370
|
-
heading(text: string, level: number, raw: string
|
|
208
|
+
heading(text: string, level: number, raw: string): string;
|
|
371
209
|
hr(): string;
|
|
372
210
|
list(body: string, ordered: boolean, start: number | ''): string;
|
|
373
211
|
listitem(text: string, task: boolean, checked: boolean): string;
|
|
@@ -392,10 +230,26 @@ declare module "Renderer" {
|
|
|
392
230
|
text(text: string): string;
|
|
393
231
|
}
|
|
394
232
|
}
|
|
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
|
+
}
|
|
249
|
+
}
|
|
395
250
|
declare module "Parser" {
|
|
396
251
|
import { _Renderer } from "Renderer";
|
|
397
252
|
import { _TextRenderer } from "TextRenderer";
|
|
398
|
-
import { _Slugger } from "Slugger";
|
|
399
253
|
import type { Token } from "Tokens";
|
|
400
254
|
import type { MarkedOptions } from "MarkedOptions";
|
|
401
255
|
/**
|
|
@@ -405,7 +259,6 @@ declare module "Parser" {
|
|
|
405
259
|
options: MarkedOptions;
|
|
406
260
|
renderer: _Renderer;
|
|
407
261
|
textRenderer: _TextRenderer;
|
|
408
|
-
slugger: _Slugger;
|
|
409
262
|
constructor(options?: MarkedOptions);
|
|
410
263
|
/**
|
|
411
264
|
* Static Parse Method
|
|
@@ -425,16 +278,96 @@ declare module "Parser" {
|
|
|
425
278
|
parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
|
|
426
279
|
}
|
|
427
280
|
}
|
|
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
|
+
}
|
|
318
|
+
}
|
|
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
|
+
}
|
|
364
|
+
}
|
|
428
365
|
declare module "MarkedOptions" {
|
|
429
366
|
import type { Token, Tokens, TokensList } from "Tokens";
|
|
430
367
|
import type { _Parser } from "Parser";
|
|
431
368
|
import type { _Lexer } from "Lexer";
|
|
432
369
|
import type { _Renderer } from "Renderer";
|
|
433
370
|
import type { _Tokenizer } from "Tokenizer";
|
|
434
|
-
export interface SluggerOptions {
|
|
435
|
-
/** Generates the next unique slug without updating the internal accumulator. */
|
|
436
|
-
dryrun?: boolean;
|
|
437
|
-
}
|
|
438
371
|
export interface TokenizerThis {
|
|
439
372
|
lexer: _Lexer;
|
|
440
373
|
}
|
|
@@ -469,11 +402,6 @@ declare module "MarkedOptions" {
|
|
|
469
402
|
* True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
|
|
470
403
|
*/
|
|
471
404
|
async?: boolean;
|
|
472
|
-
/**
|
|
473
|
-
* A prefix URL for any relative link.
|
|
474
|
-
* @deprecated Deprecated in v5.0.0 use marked-base-url to prefix url for any relative link.
|
|
475
|
-
*/
|
|
476
|
-
baseUrl?: string | undefined | null;
|
|
477
405
|
/**
|
|
478
406
|
* Enable GFM line breaks. This option requires the gfm option to be true.
|
|
479
407
|
*/
|
|
@@ -486,24 +414,6 @@ declare module "MarkedOptions" {
|
|
|
486
414
|
* Enable GitHub flavored markdown.
|
|
487
415
|
*/
|
|
488
416
|
gfm?: boolean | undefined;
|
|
489
|
-
/**
|
|
490
|
-
* Include an id attribute when emitting headings.
|
|
491
|
-
* @deprecated Deprecated in v5.0.0 use marked-gfm-heading-id to include an id attribute when emitting headings (h1, h2, h3, etc).
|
|
492
|
-
*/
|
|
493
|
-
headerIds?: boolean | undefined;
|
|
494
|
-
/**
|
|
495
|
-
* Set the prefix for header tag ids.
|
|
496
|
-
* @deprecated Deprecated in v5.0.0 use marked-gfm-heading-id to add a string to prefix the id attribute when emitting headings (h1, h2, h3, etc).
|
|
497
|
-
*/
|
|
498
|
-
headerPrefix?: string | undefined;
|
|
499
|
-
/**
|
|
500
|
-
* A function to highlight code blocks. The function can either be
|
|
501
|
-
* synchronous (returning a string) or asynchronous (callback invoked
|
|
502
|
-
* with an error if any occurred during highlighting and a string
|
|
503
|
-
* if highlighting was successful)
|
|
504
|
-
* @deprecated Deprecated in v5.0.0 use marked-highlight to add highlighting to code blocks.
|
|
505
|
-
*/
|
|
506
|
-
highlight?: ((code: string, lang: string | undefined, callback?: (error: Error, code?: string) => void) => string | void) | null;
|
|
507
417
|
/**
|
|
508
418
|
* Hooks are methods that hook into some part of marked.
|
|
509
419
|
* preprocess is called to process markdown before sending it to marked.
|
|
@@ -514,16 +424,6 @@ declare module "MarkedOptions" {
|
|
|
514
424
|
postprocess: (html: string) => string | Promise<string>;
|
|
515
425
|
options?: MarkedOptions;
|
|
516
426
|
} | null;
|
|
517
|
-
/**
|
|
518
|
-
* Set the prefix for code block classes.
|
|
519
|
-
* @deprecated Deprecated in v5.0.0 use marked-highlight to prefix the className in a <code> block. Useful for syntax highlighting.
|
|
520
|
-
*/
|
|
521
|
-
langPrefix?: string | undefined;
|
|
522
|
-
/**
|
|
523
|
-
* Mangle autolinks (<email@domain.com>).
|
|
524
|
-
* @deprecated Deprecated in v5.0.0 use marked-mangle to mangle email addresses.
|
|
525
|
-
*/
|
|
526
|
-
mangle?: boolean | undefined;
|
|
527
427
|
/**
|
|
528
428
|
* Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
|
|
529
429
|
*/
|
|
@@ -534,29 +434,10 @@ declare module "MarkedOptions" {
|
|
|
534
434
|
* An object containing functions to render tokens to HTML.
|
|
535
435
|
*/
|
|
536
436
|
renderer?: RendererObject | undefined | null;
|
|
537
|
-
/**
|
|
538
|
-
* Sanitize the output. Ignore any HTML that has been input. If true, sanitize the HTML passed into markdownString with the sanitizer function.
|
|
539
|
-
* @deprecated Warning: This feature is deprecated and it should NOT be used as it cannot be considered secure. Instead use a sanitize library, like DOMPurify (recommended), sanitize-html or insane on the output HTML!
|
|
540
|
-
*/
|
|
541
|
-
sanitize?: boolean | undefined;
|
|
542
|
-
/**
|
|
543
|
-
* Optionally sanitize found HTML with a sanitizer function.
|
|
544
|
-
* @deprecated A function to sanitize the HTML passed into markdownString.
|
|
545
|
-
*/
|
|
546
|
-
sanitizer?: ((html: string) => string) | null;
|
|
547
437
|
/**
|
|
548
438
|
* Shows an HTML error message when rendering fails.
|
|
549
439
|
*/
|
|
550
440
|
silent?: boolean | undefined;
|
|
551
|
-
/**
|
|
552
|
-
* Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
|
|
553
|
-
*/
|
|
554
|
-
smartLists?: boolean | undefined;
|
|
555
|
-
/**
|
|
556
|
-
* Use "smart" typograhic punctuation for things like quotes and dashes.
|
|
557
|
-
* @deprecated Deprecated in v5.0.0 use marked-smartypants to use "smart" typographic punctuation for things like quotes and dashes.
|
|
558
|
-
*/
|
|
559
|
-
smartypants?: boolean | undefined;
|
|
560
441
|
/**
|
|
561
442
|
* The tokenizer defines how to turn markdown text into tokens.
|
|
562
443
|
*/
|
|
@@ -567,12 +448,7 @@ declare module "MarkedOptions" {
|
|
|
567
448
|
* Each token is passed by reference so updates are persisted when passed to the parser.
|
|
568
449
|
* The return value of the function is ignored.
|
|
569
450
|
*/
|
|
570
|
-
walkTokens?: ((token: Token) => void |
|
|
571
|
-
/**
|
|
572
|
-
* Generate closing slash for self-closing tags (<br/> instead of <br>)
|
|
573
|
-
* @deprecated Deprecated in v5.0.0 use marked-xhtml to emit self-closing HTML tags for void elements (<br/>, <img/>, etc.) with a "/" as required by XHTML.
|
|
574
|
-
*/
|
|
575
|
-
xhtml?: boolean | undefined;
|
|
451
|
+
walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
|
|
576
452
|
}
|
|
577
453
|
export interface MarkedOptions extends Omit<MarkedExtension, 'renderer' | 'tokenizer' | 'extensions' | 'walkTokens'> {
|
|
578
454
|
/**
|
|
@@ -603,7 +479,7 @@ declare module "MarkedOptions" {
|
|
|
603
479
|
/**
|
|
604
480
|
* walkTokens function returns array of values for Promise.all
|
|
605
481
|
*/
|
|
606
|
-
walkTokens?: null | ((token: Token) => void | (
|
|
482
|
+
walkTokens?: null | ((token: Token) => void | Promise<void> | (void | Promise<void>)[]);
|
|
607
483
|
}
|
|
608
484
|
}
|
|
609
485
|
declare module "defaults" {
|
|
@@ -631,18 +507,50 @@ declare module "Hooks" {
|
|
|
631
507
|
postprocess(html: string): string;
|
|
632
508
|
}
|
|
633
509
|
}
|
|
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
|
+
}
|
|
542
|
+
}
|
|
634
543
|
declare module "marked" {
|
|
635
544
|
import { _Lexer } from "Lexer";
|
|
636
545
|
import { _Parser } from "Parser";
|
|
637
546
|
import { _Tokenizer } from "Tokenizer";
|
|
638
547
|
import { _Renderer } from "Renderer";
|
|
639
548
|
import { _TextRenderer } from "TextRenderer";
|
|
640
|
-
import { _Slugger } from "Slugger";
|
|
641
549
|
import { _Hooks } from "Hooks";
|
|
642
550
|
import { _getDefaults } from "defaults";
|
|
643
551
|
import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
|
|
644
552
|
import type { Token, TokensList } from "Tokens";
|
|
645
|
-
import type {
|
|
553
|
+
import type { MaybePromise } from "Instance";
|
|
646
554
|
/**
|
|
647
555
|
* Compiles markdown to HTML asynchronously.
|
|
648
556
|
*
|
|
@@ -662,26 +570,11 @@ declare module "marked" {
|
|
|
662
570
|
*/
|
|
663
571
|
export function marked(src: string, options?: MarkedOptions): string;
|
|
664
572
|
/**
|
|
665
|
-
* Compiles markdown to HTML
|
|
666
|
-
*
|
|
667
|
-
* @param src String of markdown source to be compiled
|
|
668
|
-
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
|
669
|
-
*/
|
|
670
|
-
export function marked(src: string, callback: ResultCallback): void;
|
|
671
|
-
/**
|
|
672
|
-
* Compiles markdown to HTML asynchronously with a callback.
|
|
673
|
-
*
|
|
674
|
-
* @param src String of markdown source to be compiled
|
|
675
|
-
* @param options Hash of options
|
|
676
|
-
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
|
677
|
-
*/
|
|
678
|
-
export function marked(src: string, options: MarkedOptions, callback: ResultCallback): void;
|
|
679
|
-
/**
|
|
680
|
-
* Compiles markdown to HTML asynchronously with a callback.
|
|
573
|
+
* Compiles markdown to HTML synchronously.
|
|
681
574
|
*
|
|
682
575
|
* @param src String of markdown source to be compiled
|
|
683
|
-
* @param options
|
|
684
|
-
* @
|
|
576
|
+
* @param options Optional hash of options
|
|
577
|
+
* @return String of compiled HTML
|
|
685
578
|
*/
|
|
686
579
|
export namespace marked {
|
|
687
580
|
var options: (options: MarkedOptions) => typeof marked;
|
|
@@ -689,8 +582,8 @@ declare module "marked" {
|
|
|
689
582
|
var getDefaults: typeof _getDefaults;
|
|
690
583
|
var defaults: MarkedOptions;
|
|
691
584
|
var use: (...args: MarkedExtension[]) => typeof marked;
|
|
692
|
-
var walkTokens:
|
|
693
|
-
var parseInline: (src: string,
|
|
585
|
+
var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
|
586
|
+
var parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
|
694
587
|
var Parser: typeof _Parser;
|
|
695
588
|
var parser: typeof _Parser.parse;
|
|
696
589
|
var Renderer: typeof _Renderer;
|
|
@@ -698,15 +591,14 @@ declare module "marked" {
|
|
|
698
591
|
var Lexer: typeof _Lexer;
|
|
699
592
|
var lexer: typeof _Lexer.lex;
|
|
700
593
|
var Tokenizer: typeof _Tokenizer;
|
|
701
|
-
var Slugger: typeof _Slugger;
|
|
702
594
|
var Hooks: typeof _Hooks;
|
|
703
595
|
var parse: typeof marked;
|
|
704
596
|
}
|
|
705
597
|
export const options: (options: MarkedOptions) => typeof marked;
|
|
706
598
|
export const setOptions: (options: MarkedOptions) => typeof marked;
|
|
707
599
|
export const use: (...args: MarkedExtension[]) => typeof marked;
|
|
708
|
-
export const walkTokens:
|
|
709
|
-
export const parseInline: (src: string,
|
|
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>;
|
|
710
602
|
export const parse: typeof marked;
|
|
711
603
|
export const parser: typeof _Parser.parse;
|
|
712
604
|
export const lexer: typeof _Lexer.lex;
|
|
@@ -716,7 +608,6 @@ declare module "marked" {
|
|
|
716
608
|
export { _Tokenizer as Tokenizer } from "Tokenizer";
|
|
717
609
|
export { _Renderer as Renderer } from "Renderer";
|
|
718
610
|
export { _TextRenderer as TextRenderer } from "TextRenderer";
|
|
719
|
-
export { _Slugger as Slugger } from "Slugger";
|
|
720
611
|
export { _Hooks as Hooks } from "Hooks";
|
|
721
612
|
export { Marked } from "Instance";
|
|
722
613
|
export type * from "MarkedOptions";
|