marked 7.0.5 → 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 +142 -252
- 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 +6 -6
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,129 +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 type MaybePromise = void | Promise<void>;
|
|
307
|
-
export class Marked {
|
|
308
|
-
#private;
|
|
309
|
-
defaults: MarkedOptions;
|
|
310
|
-
options: (opt: MarkedOptions) => this;
|
|
311
|
-
parse: (src: string, optOrCallback?: MarkedOptions | ResultCallback | undefined | null, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
|
312
|
-
parseInline: (src: string, optOrCallback?: MarkedOptions | ResultCallback | undefined | null, callback?: ResultCallback | undefined) => string | Promise<string | undefined> | undefined;
|
|
313
|
-
Parser: typeof _Parser;
|
|
314
|
-
parser: typeof _Parser.parse;
|
|
315
|
-
Renderer: typeof _Renderer;
|
|
316
|
-
TextRenderer: typeof _TextRenderer;
|
|
317
|
-
Lexer: typeof _Lexer;
|
|
318
|
-
lexer: typeof _Lexer.lex;
|
|
319
|
-
Tokenizer: typeof _Tokenizer;
|
|
320
|
-
Slugger: typeof _Slugger;
|
|
321
|
-
Hooks: typeof _Hooks;
|
|
322
|
-
constructor(...args: MarkedExtension[]);
|
|
323
|
-
/**
|
|
324
|
-
* Run callback for every token
|
|
325
|
-
*/
|
|
326
|
-
walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
|
|
327
|
-
use(...args: MarkedExtension[]): this;
|
|
328
|
-
setOptions(opt: MarkedOptions): this;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
173
|
declare module "helpers" {
|
|
332
|
-
import type { MarkedOptions } from "MarkedOptions";
|
|
333
|
-
import type { ResultCallback } from "Instance";
|
|
334
174
|
import type { Rule } from "rules";
|
|
335
175
|
export function escape(html: string, encode?: boolean): string;
|
|
336
176
|
export function unescape(html: string): string;
|
|
@@ -338,8 +178,7 @@ declare module "helpers" {
|
|
|
338
178
|
replace: (name: string | RegExp, val: string | RegExp) => any;
|
|
339
179
|
getRegex: () => RegExp;
|
|
340
180
|
};
|
|
341
|
-
export function cleanUrl(
|
|
342
|
-
export function resolveUrl(base: string, href: string): string;
|
|
181
|
+
export function cleanUrl(href: string): string | null;
|
|
343
182
|
export const noopTest: {
|
|
344
183
|
exec: () => null;
|
|
345
184
|
};
|
|
@@ -354,11 +193,9 @@ declare module "helpers" {
|
|
|
354
193
|
*/
|
|
355
194
|
export function rtrim(str: string, c: string, invert?: boolean): string;
|
|
356
195
|
export function findClosingBracket(str: string, b: string): number;
|
|
357
|
-
export function checkDeprecations(opt: MarkedOptions, callback?: ResultCallback): void;
|
|
358
196
|
}
|
|
359
197
|
declare module "Renderer" {
|
|
360
198
|
import type { MarkedOptions } from "MarkedOptions";
|
|
361
|
-
import type { _Slugger } from "Slugger";
|
|
362
199
|
/**
|
|
363
200
|
* Renderer
|
|
364
201
|
*/
|
|
@@ -368,7 +205,7 @@ declare module "Renderer" {
|
|
|
368
205
|
code(code: string, infostring: string | undefined, escaped: boolean): string;
|
|
369
206
|
blockquote(quote: string): string;
|
|
370
207
|
html(html: string, block?: boolean): string;
|
|
371
|
-
heading(text: string, level: number, raw: string
|
|
208
|
+
heading(text: string, level: number, raw: string): string;
|
|
372
209
|
hr(): string;
|
|
373
210
|
list(body: string, ordered: boolean, start: number | ''): string;
|
|
374
211
|
listitem(text: string, task: boolean, checked: boolean): string;
|
|
@@ -393,10 +230,26 @@ declare module "Renderer" {
|
|
|
393
230
|
text(text: string): string;
|
|
394
231
|
}
|
|
395
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
|
+
}
|
|
396
250
|
declare module "Parser" {
|
|
397
251
|
import { _Renderer } from "Renderer";
|
|
398
252
|
import { _TextRenderer } from "TextRenderer";
|
|
399
|
-
import { _Slugger } from "Slugger";
|
|
400
253
|
import type { Token } from "Tokens";
|
|
401
254
|
import type { MarkedOptions } from "MarkedOptions";
|
|
402
255
|
/**
|
|
@@ -406,7 +259,6 @@ declare module "Parser" {
|
|
|
406
259
|
options: MarkedOptions;
|
|
407
260
|
renderer: _Renderer;
|
|
408
261
|
textRenderer: _TextRenderer;
|
|
409
|
-
slugger: _Slugger;
|
|
410
262
|
constructor(options?: MarkedOptions);
|
|
411
263
|
/**
|
|
412
264
|
* Static Parse Method
|
|
@@ -426,16 +278,96 @@ declare module "Parser" {
|
|
|
426
278
|
parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
|
|
427
279
|
}
|
|
428
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
|
+
}
|
|
429
365
|
declare module "MarkedOptions" {
|
|
430
366
|
import type { Token, Tokens, TokensList } from "Tokens";
|
|
431
367
|
import type { _Parser } from "Parser";
|
|
432
368
|
import type { _Lexer } from "Lexer";
|
|
433
369
|
import type { _Renderer } from "Renderer";
|
|
434
370
|
import type { _Tokenizer } from "Tokenizer";
|
|
435
|
-
export interface SluggerOptions {
|
|
436
|
-
/** Generates the next unique slug without updating the internal accumulator. */
|
|
437
|
-
dryrun?: boolean;
|
|
438
|
-
}
|
|
439
371
|
export interface TokenizerThis {
|
|
440
372
|
lexer: _Lexer;
|
|
441
373
|
}
|
|
@@ -470,11 +402,6 @@ declare module "MarkedOptions" {
|
|
|
470
402
|
* True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
|
|
471
403
|
*/
|
|
472
404
|
async?: boolean;
|
|
473
|
-
/**
|
|
474
|
-
* A prefix URL for any relative link.
|
|
475
|
-
* @deprecated Deprecated in v5.0.0 use marked-base-url to prefix url for any relative link.
|
|
476
|
-
*/
|
|
477
|
-
baseUrl?: string | undefined | null;
|
|
478
405
|
/**
|
|
479
406
|
* Enable GFM line breaks. This option requires the gfm option to be true.
|
|
480
407
|
*/
|
|
@@ -487,24 +414,6 @@ declare module "MarkedOptions" {
|
|
|
487
414
|
* Enable GitHub flavored markdown.
|
|
488
415
|
*/
|
|
489
416
|
gfm?: boolean | undefined;
|
|
490
|
-
/**
|
|
491
|
-
* Include an id attribute when emitting headings.
|
|
492
|
-
* @deprecated Deprecated in v5.0.0 use marked-gfm-heading-id to include an id attribute when emitting headings (h1, h2, h3, etc).
|
|
493
|
-
*/
|
|
494
|
-
headerIds?: boolean | undefined;
|
|
495
|
-
/**
|
|
496
|
-
* Set the prefix for header tag ids.
|
|
497
|
-
* @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).
|
|
498
|
-
*/
|
|
499
|
-
headerPrefix?: string | undefined;
|
|
500
|
-
/**
|
|
501
|
-
* A function to highlight code blocks. The function can either be
|
|
502
|
-
* synchronous (returning a string) or asynchronous (callback invoked
|
|
503
|
-
* with an error if any occurred during highlighting and a string
|
|
504
|
-
* if highlighting was successful)
|
|
505
|
-
* @deprecated Deprecated in v5.0.0 use marked-highlight to add highlighting to code blocks.
|
|
506
|
-
*/
|
|
507
|
-
highlight?: ((code: string, lang: string | undefined, callback?: (error: Error, code?: string) => void) => string | void) | null;
|
|
508
417
|
/**
|
|
509
418
|
* Hooks are methods that hook into some part of marked.
|
|
510
419
|
* preprocess is called to process markdown before sending it to marked.
|
|
@@ -515,16 +424,6 @@ declare module "MarkedOptions" {
|
|
|
515
424
|
postprocess: (html: string) => string | Promise<string>;
|
|
516
425
|
options?: MarkedOptions;
|
|
517
426
|
} | null;
|
|
518
|
-
/**
|
|
519
|
-
* Set the prefix for code block classes.
|
|
520
|
-
* @deprecated Deprecated in v5.0.0 use marked-highlight to prefix the className in a <code> block. Useful for syntax highlighting.
|
|
521
|
-
*/
|
|
522
|
-
langPrefix?: string | undefined;
|
|
523
|
-
/**
|
|
524
|
-
* Mangle autolinks (<email@domain.com>).
|
|
525
|
-
* @deprecated Deprecated in v5.0.0 use marked-mangle to mangle email addresses.
|
|
526
|
-
*/
|
|
527
|
-
mangle?: boolean | undefined;
|
|
528
427
|
/**
|
|
529
428
|
* Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
|
|
530
429
|
*/
|
|
@@ -535,29 +434,10 @@ declare module "MarkedOptions" {
|
|
|
535
434
|
* An object containing functions to render tokens to HTML.
|
|
536
435
|
*/
|
|
537
436
|
renderer?: RendererObject | undefined | null;
|
|
538
|
-
/**
|
|
539
|
-
* Sanitize the output. Ignore any HTML that has been input. If true, sanitize the HTML passed into markdownString with the sanitizer function.
|
|
540
|
-
* @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!
|
|
541
|
-
*/
|
|
542
|
-
sanitize?: boolean | undefined;
|
|
543
|
-
/**
|
|
544
|
-
* Optionally sanitize found HTML with a sanitizer function.
|
|
545
|
-
* @deprecated A function to sanitize the HTML passed into markdownString.
|
|
546
|
-
*/
|
|
547
|
-
sanitizer?: ((html: string) => string) | null;
|
|
548
437
|
/**
|
|
549
438
|
* Shows an HTML error message when rendering fails.
|
|
550
439
|
*/
|
|
551
440
|
silent?: boolean | undefined;
|
|
552
|
-
/**
|
|
553
|
-
* Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
|
|
554
|
-
*/
|
|
555
|
-
smartLists?: boolean | undefined;
|
|
556
|
-
/**
|
|
557
|
-
* Use "smart" typograhic punctuation for things like quotes and dashes.
|
|
558
|
-
* @deprecated Deprecated in v5.0.0 use marked-smartypants to use "smart" typographic punctuation for things like quotes and dashes.
|
|
559
|
-
*/
|
|
560
|
-
smartypants?: boolean | undefined;
|
|
561
441
|
/**
|
|
562
442
|
* The tokenizer defines how to turn markdown text into tokens.
|
|
563
443
|
*/
|
|
@@ -569,11 +449,6 @@ declare module "MarkedOptions" {
|
|
|
569
449
|
* The return value of the function is ignored.
|
|
570
450
|
*/
|
|
571
451
|
walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
|
|
572
|
-
/**
|
|
573
|
-
* Generate closing slash for self-closing tags (<br/> instead of <br>)
|
|
574
|
-
* @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.
|
|
575
|
-
*/
|
|
576
|
-
xhtml?: boolean | undefined;
|
|
577
452
|
}
|
|
578
453
|
export interface MarkedOptions extends Omit<MarkedExtension, 'renderer' | 'tokenizer' | 'extensions' | 'walkTokens'> {
|
|
579
454
|
/**
|
|
@@ -632,18 +507,50 @@ declare module "Hooks" {
|
|
|
632
507
|
postprocess(html: string): string;
|
|
633
508
|
}
|
|
634
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
|
+
}
|
|
635
543
|
declare module "marked" {
|
|
636
544
|
import { _Lexer } from "Lexer";
|
|
637
545
|
import { _Parser } from "Parser";
|
|
638
546
|
import { _Tokenizer } from "Tokenizer";
|
|
639
547
|
import { _Renderer } from "Renderer";
|
|
640
548
|
import { _TextRenderer } from "TextRenderer";
|
|
641
|
-
import { _Slugger } from "Slugger";
|
|
642
549
|
import { _Hooks } from "Hooks";
|
|
643
550
|
import { _getDefaults } from "defaults";
|
|
644
551
|
import type { MarkedExtension, MarkedOptions } from "MarkedOptions";
|
|
645
552
|
import type { Token, TokensList } from "Tokens";
|
|
646
|
-
import type {
|
|
553
|
+
import type { MaybePromise } from "Instance";
|
|
647
554
|
/**
|
|
648
555
|
* Compiles markdown to HTML asynchronously.
|
|
649
556
|
*
|
|
@@ -663,26 +570,11 @@ declare module "marked" {
|
|
|
663
570
|
*/
|
|
664
571
|
export function marked(src: string, options?: MarkedOptions): string;
|
|
665
572
|
/**
|
|
666
|
-
* Compiles markdown to HTML
|
|
667
|
-
*
|
|
668
|
-
* @param src String of markdown source to be compiled
|
|
669
|
-
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
|
670
|
-
*/
|
|
671
|
-
export function marked(src: string, callback: ResultCallback): void;
|
|
672
|
-
/**
|
|
673
|
-
* Compiles markdown to HTML asynchronously with a callback.
|
|
674
|
-
*
|
|
675
|
-
* @param src String of markdown source to be compiled
|
|
676
|
-
* @param options Hash of options
|
|
677
|
-
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
|
678
|
-
*/
|
|
679
|
-
export function marked(src: string, options: MarkedOptions, callback: ResultCallback): void;
|
|
680
|
-
/**
|
|
681
|
-
* Compiles markdown to HTML asynchronously with a callback.
|
|
573
|
+
* Compiles markdown to HTML synchronously.
|
|
682
574
|
*
|
|
683
575
|
* @param src String of markdown source to be compiled
|
|
684
|
-
* @param options
|
|
685
|
-
* @
|
|
576
|
+
* @param options Optional hash of options
|
|
577
|
+
* @return String of compiled HTML
|
|
686
578
|
*/
|
|
687
579
|
export namespace marked {
|
|
688
580
|
var options: (options: MarkedOptions) => typeof marked;
|
|
@@ -691,7 +583,7 @@ declare module "marked" {
|
|
|
691
583
|
var defaults: MarkedOptions;
|
|
692
584
|
var use: (...args: MarkedExtension[]) => typeof marked;
|
|
693
585
|
var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
|
694
|
-
var parseInline: (src: string,
|
|
586
|
+
var parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
|
695
587
|
var Parser: typeof _Parser;
|
|
696
588
|
var parser: typeof _Parser.parse;
|
|
697
589
|
var Renderer: typeof _Renderer;
|
|
@@ -699,7 +591,6 @@ declare module "marked" {
|
|
|
699
591
|
var Lexer: typeof _Lexer;
|
|
700
592
|
var lexer: typeof _Lexer.lex;
|
|
701
593
|
var Tokenizer: typeof _Tokenizer;
|
|
702
|
-
var Slugger: typeof _Slugger;
|
|
703
594
|
var Hooks: typeof _Hooks;
|
|
704
595
|
var parse: typeof marked;
|
|
705
596
|
}
|
|
@@ -707,7 +598,7 @@ declare module "marked" {
|
|
|
707
598
|
export const setOptions: (options: MarkedOptions) => typeof marked;
|
|
708
599
|
export const use: (...args: MarkedExtension[]) => typeof marked;
|
|
709
600
|
export const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
|
710
|
-
export const parseInline: (src: string,
|
|
601
|
+
export const parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
|
711
602
|
export const parse: typeof marked;
|
|
712
603
|
export const parser: typeof _Parser.parse;
|
|
713
604
|
export const lexer: typeof _Lexer.lex;
|
|
@@ -717,7 +608,6 @@ declare module "marked" {
|
|
|
717
608
|
export { _Tokenizer as Tokenizer } from "Tokenizer";
|
|
718
609
|
export { _Renderer as Renderer } from "Renderer";
|
|
719
610
|
export { _TextRenderer as TextRenderer } from "TextRenderer";
|
|
720
|
-
export { _Slugger as Slugger } from "Slugger";
|
|
721
611
|
export { _Hooks as Hooks } from "Hooks";
|
|
722
612
|
export { Marked } from "Instance";
|
|
723
613
|
export type * from "MarkedOptions";
|