marked 5.1.2 → 7.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.
@@ -1,49 +1,56 @@
1
- import { getDefaults } from './defaults.js';
2
- import { Lexer } from './Lexer.js';
3
- import { Parser } from './Parser.js';
4
- import { Hooks } from './Hooks.js';
5
- import { Renderer } from './Renderer.js';
6
- import { Tokenizer } from './Tokenizer.js';
7
- import { TextRenderer } from './TextRenderer.js';
8
- import { Slugger } from './Slugger.js';
1
+ import { _getDefaults } from './defaults.js';
2
+ import { _Lexer } from './Lexer.ts';
3
+ import { _Parser } from './Parser.ts';
4
+ import { _Hooks } from './Hooks.ts';
5
+ import { _Renderer } from './Renderer.ts';
6
+ import { _Tokenizer } from './Tokenizer.ts';
7
+ import { _TextRenderer } from './TextRenderer.ts';
8
+ import { _Slugger } from './Slugger.ts';
9
9
  import {
10
10
  checkDeprecations,
11
11
  escape
12
- } from './helpers.js';
12
+ } from './helpers.ts';
13
+ import type { MarkedExtension, MarkedOptions } from './MarkedOptions.ts';
14
+ import type { Token, TokensList } from './Tokens.ts';
15
+
16
+ export type ResultCallback = (error: Error | null, parseResult?: string) => undefined | void;
13
17
 
14
18
  export class Marked {
15
- defaults = getDefaults();
19
+ defaults = _getDefaults();
16
20
  options = this.setOptions;
17
21
 
18
- parse = this.#parseMarkdown(Lexer.lex, Parser.parse);
19
- parseInline = this.#parseMarkdown(Lexer.lexInline, Parser.parseInline);
22
+ parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse);
23
+ parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline);
20
24
 
21
- Parser = Parser;
22
- parser = Parser.parse;
23
- Renderer = Renderer;
24
- TextRenderer = TextRenderer;
25
- Lexer = Lexer;
26
- lexer = Lexer.lex;
27
- Tokenizer = Tokenizer;
28
- Slugger = Slugger;
29
- Hooks = Hooks;
25
+ Parser = _Parser;
26
+ parser = _Parser.parse;
27
+ Renderer = _Renderer;
28
+ TextRenderer = _TextRenderer;
29
+ Lexer = _Lexer;
30
+ lexer = _Lexer.lex;
31
+ Tokenizer = _Tokenizer;
32
+ Slugger = _Slugger;
33
+ Hooks = _Hooks;
30
34
 
31
- constructor(...args) {
35
+ constructor(...args: MarkedExtension[]) {
32
36
  this.use(...args);
33
37
  }
34
38
 
35
- walkTokens(tokens, callback) {
36
- let values = [];
39
+ /**
40
+ * Run callback for every token
41
+ */
42
+ walkTokens <T = void>(tokens: Token[] | TokensList, callback: (token: Token) => T | T[]) {
43
+ let values: T[] = [];
37
44
  for (const token of tokens) {
38
45
  values = values.concat(callback.call(this, token));
39
46
  switch (token.type) {
40
47
  case 'table': {
41
48
  for (const cell of token.header) {
42
- values = values.concat(this.walkTokens(cell.tokens, callback));
49
+ values = values.concat(this.walkTokens(cell.tokens!, callback));
43
50
  }
44
51
  for (const row of token.rows) {
45
52
  for (const cell of row) {
46
- values = values.concat(this.walkTokens(cell.tokens, callback));
53
+ values = values.concat(this.walkTokens(cell.tokens!, callback));
47
54
  }
48
55
  }
49
56
  break;
@@ -66,12 +73,12 @@ export class Marked {
66
73
  return values;
67
74
  }
68
75
 
69
- use(...args) {
70
- const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
76
+ use(...args: MarkedExtension[]) {
77
+ const extensions: NonNullable<MarkedOptions['extensions']> = this.defaults.extensions || { renderers: {}, childTokens: {} } as NonNullable<MarkedOptions['extensions']>;
71
78
 
72
79
  args.forEach((pack) => {
73
80
  // copy options to new object
74
- const opts = { ...pack };
81
+ const opts = { ...pack } as MarkedOptions;
75
82
 
76
83
  // set async to true if it was set to true before
77
84
  opts.async = this.defaults.async || opts.async || false;
@@ -82,7 +89,7 @@ export class Marked {
82
89
  if (!ext.name) {
83
90
  throw new Error('extension name required');
84
91
  }
85
- if (ext.renderer) { // Renderer extensions
92
+ if ('renderer' in ext) { // Renderer extensions
86
93
  const prevRenderer = extensions.renderers[ext.name];
87
94
  if (prevRenderer) {
88
95
  // Replace extension with func to run new extension but fall back if false
@@ -97,7 +104,7 @@ export class Marked {
97
104
  extensions.renderers[ext.name] = ext.renderer;
98
105
  }
99
106
  }
100
- if (ext.tokenizer) { // Tokenizer Extensions
107
+ if ('tokenizer' in ext) { // Tokenizer Extensions
101
108
  if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) {
102
109
  throw new Error("extension level must be 'block' or 'inline'");
103
110
  }
@@ -109,20 +116,20 @@ export class Marked {
109
116
  if (ext.start) { // Function to check for start of token
110
117
  if (ext.level === 'block') {
111
118
  if (extensions.startBlock) {
112
- extensions.startBlock.push(ext.start);
119
+ extensions.startBlock.push(ext.start!);
113
120
  } else {
114
- extensions.startBlock = [ext.start];
121
+ extensions.startBlock = [ext.start!];
115
122
  }
116
123
  } else if (ext.level === 'inline') {
117
124
  if (extensions.startInline) {
118
- extensions.startInline.push(ext.start);
125
+ extensions.startInline.push(ext.start!);
119
126
  } else {
120
- extensions.startInline = [ext.start];
127
+ extensions.startInline = [ext.start!];
121
128
  }
122
129
  }
123
130
  }
124
131
  }
125
- if (ext.childTokens) { // Child tokens to be visited by walkTokens
132
+ if ('childTokens' in ext && ext.childTokens) { // Child tokens to be visited by walkTokens
126
133
  extensions.childTokens[ext.name] = ext.childTokens;
127
134
  }
128
135
  });
@@ -131,12 +138,12 @@ export class Marked {
131
138
 
132
139
  // ==-- Parse "overwrite" extensions --== //
133
140
  if (pack.renderer) {
134
- const renderer = this.defaults.renderer || new Renderer(this.defaults);
141
+ const renderer = this.defaults.renderer || new _Renderer(this.defaults);
135
142
  for (const prop in pack.renderer) {
136
143
  const prevRenderer = renderer[prop];
137
144
  // Replace renderer with func to run extension, but fall back if false
138
- renderer[prop] = (...args) => {
139
- let ret = pack.renderer[prop].apply(renderer, args);
145
+ renderer[prop] = (...args: unknown[]) => {
146
+ let ret = pack.renderer![prop].apply(renderer, args);
140
147
  if (ret === false) {
141
148
  ret = prevRenderer.apply(renderer, args);
142
149
  }
@@ -146,12 +153,12 @@ export class Marked {
146
153
  opts.renderer = renderer;
147
154
  }
148
155
  if (pack.tokenizer) {
149
- const tokenizer = this.defaults.tokenizer || new Tokenizer(this.defaults);
156
+ const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
150
157
  for (const prop in pack.tokenizer) {
151
158
  const prevTokenizer = tokenizer[prop];
152
159
  // Replace tokenizer with func to run extension, but fall back if false
153
- tokenizer[prop] = (...args) => {
154
- let ret = pack.tokenizer[prop].apply(tokenizer, args);
160
+ tokenizer[prop] = (...args: unknown[]) => {
161
+ let ret = pack.tokenizer![prop].apply(tokenizer, args);
155
162
  if (ret === false) {
156
163
  ret = prevTokenizer.apply(tokenizer, args);
157
164
  }
@@ -163,23 +170,23 @@ export class Marked {
163
170
 
164
171
  // ==-- Parse Hooks extensions --== //
165
172
  if (pack.hooks) {
166
- const hooks = this.defaults.hooks || new Hooks();
173
+ const hooks = this.defaults.hooks || new _Hooks();
167
174
  for (const prop in pack.hooks) {
168
175
  const prevHook = hooks[prop];
169
- if (Hooks.passThroughHooks.has(prop)) {
170
- hooks[prop] = (arg) => {
176
+ if (_Hooks.passThroughHooks.has(prop)) {
177
+ hooks[prop as 'preprocess' | 'postprocess'] = (arg: string | undefined) => {
171
178
  if (this.defaults.async) {
172
- return Promise.resolve(pack.hooks[prop].call(hooks, arg)).then(ret => {
179
+ return Promise.resolve(pack.hooks![prop].call(hooks, arg)).then(ret => {
173
180
  return prevHook.call(hooks, ret);
174
181
  });
175
182
  }
176
183
 
177
- const ret = pack.hooks[prop].call(hooks, arg);
184
+ const ret = pack.hooks![prop].call(hooks, arg);
178
185
  return prevHook.call(hooks, ret);
179
186
  };
180
187
  } else {
181
188
  hooks[prop] = (...args) => {
182
- let ret = pack.hooks[prop].apply(hooks, args);
189
+ let ret = pack.hooks![prop].apply(hooks, args);
183
190
  if (ret === false) {
184
191
  ret = prevHook.apply(hooks, args);
185
192
  }
@@ -194,8 +201,8 @@ export class Marked {
194
201
  if (pack.walkTokens) {
195
202
  const walkTokens = this.defaults.walkTokens;
196
203
  opts.walkTokens = function(token) {
197
- let values = [];
198
- values.push(pack.walkTokens.call(this, token));
204
+ let values: Array<Promise<void> | void> = [];
205
+ values.push(pack.walkTokens!.call(this, token));
199
206
  if (walkTokens) {
200
207
  values = values.concat(walkTokens.call(this, token));
201
208
  }
@@ -214,16 +221,16 @@ export class Marked {
214
221
  return this;
215
222
  }
216
223
 
217
- #parseMarkdown(lexer, parser) {
218
- return (src, opt, callback) => {
219
- if (typeof opt === 'function') {
220
- callback = opt;
221
- opt = null;
224
+ #parseMarkdown(lexer: (src: string, options?: MarkedOptions) => TokensList | Token[], parser: (tokens: Token[], options?: MarkedOptions) => string | undefined) {
225
+ return (src: string, optOrCallback?: MarkedOptions | ResultCallback | undefined | null, callback?: ResultCallback | undefined): string | Promise<string | undefined> | undefined => {
226
+ if (typeof optOrCallback === 'function') {
227
+ callback = optOrCallback;
228
+ optOrCallback = null;
222
229
  }
223
230
 
224
- const origOpt = { ...opt };
225
- opt = { ...this.defaults, ...origOpt };
226
- const throwError = this.#onError(opt.silent, opt.async, callback);
231
+ const origOpt = { ...optOrCallback };
232
+ const opt = { ...this.defaults, ...origOpt };
233
+ const throwError = this.#onError(!!opt.silent, !!opt.async, callback);
227
234
 
228
235
  // throw error in case of non string input
229
236
  if (typeof src === 'undefined' || src === null) {
@@ -242,7 +249,7 @@ export class Marked {
242
249
 
243
250
  if (callback) {
244
251
  const highlight = opt.highlight;
245
- let tokens;
252
+ let tokens: TokensList | Token[];
246
253
 
247
254
  try {
248
255
  if (opt.hooks) {
@@ -250,10 +257,10 @@ export class Marked {
250
257
  }
251
258
  tokens = lexer(src, opt);
252
259
  } catch (e) {
253
- return throwError(e);
260
+ return throwError(e as Error);
254
261
  }
255
262
 
256
- const done = (err) => {
263
+ const done = (err?: Error) => {
257
264
  let out;
258
265
 
259
266
  if (!err) {
@@ -261,12 +268,12 @@ export class Marked {
261
268
  if (opt.walkTokens) {
262
269
  this.walkTokens(tokens, opt.walkTokens);
263
270
  }
264
- out = parser(tokens, opt);
271
+ out = parser(tokens, opt)!;
265
272
  if (opt.hooks) {
266
273
  out = opt.hooks.postprocess(out);
267
274
  }
268
275
  } catch (e) {
269
- err = e;
276
+ err = e as Error;
270
277
  }
271
278
  }
272
279
 
@@ -274,7 +281,7 @@ export class Marked {
274
281
 
275
282
  return err
276
283
  ? throwError(err)
277
- : callback(null, out);
284
+ : callback!(null, out) as undefined;
278
285
  };
279
286
 
280
287
  if (!highlight || highlight.length < 3) {
@@ -338,13 +345,13 @@ export class Marked {
338
345
  }
339
346
  return html;
340
347
  } catch (e) {
341
- return throwError(e);
348
+ return throwError(e as Error);
342
349
  }
343
350
  };
344
351
  }
345
352
 
346
- #onError(silent, async, callback) {
347
- return (e) => {
353
+ #onError(silent: boolean, async: boolean, callback?: ResultCallback) {
354
+ return (e: Error): string | Promise<string> | undefined => {
348
355
  e.message += '\nPlease report this to https://github.com/markedjs/marked.';
349
356
 
350
357
  if (silent) {
@@ -1,12 +1,14 @@
1
- import { Tokenizer } from './Tokenizer.js';
2
- import { defaults } from './defaults.js';
3
- import { block, inline } from './rules.js';
1
+ import { _Tokenizer } from './Tokenizer.ts';
2
+ import { _defaults } from './defaults.ts';
3
+ import { block, inline } from './rules.ts';
4
+ import type { Token, TokensList } from './Tokens.ts';
5
+ import type { MarkedOptions, TokenizerExtension } from './MarkedOptions.ts';
6
+ import type { Rules } from './rules.ts';
4
7
 
5
8
  /**
6
9
  * smartypants text replacement
7
- * @param {string} text
8
10
  */
9
- function smartypants(text) {
11
+ function smartypants(text: string) {
10
12
  return text
11
13
  // em-dashes
12
14
  .replace(/---/g, '\u2014')
@@ -26,9 +28,8 @@ function smartypants(text) {
26
28
 
27
29
  /**
28
30
  * mangle email addresses
29
- * @param {string} text
30
31
  */
31
- function mangle(text) {
32
+ function mangle(text: string) {
32
33
  let out = '',
33
34
  i,
34
35
  ch;
@@ -48,12 +49,25 @@ function mangle(text) {
48
49
  /**
49
50
  * Block Lexer
50
51
  */
51
- export class Lexer {
52
- constructor(options) {
52
+ export class _Lexer {
53
+ tokens: TokensList;
54
+ options: MarkedOptions;
55
+ state: {
56
+ inLink: boolean;
57
+ inRawBlock: boolean;
58
+ top: boolean;
59
+ };
60
+
61
+ private tokenizer: _Tokenizer;
62
+ private inlineQueue: {src: string, tokens: Token[]}[];
63
+
64
+ constructor(options?: MarkedOptions) {
65
+ // TokenList cannot be created in one go
66
+ // @ts-expect-error
53
67
  this.tokens = [];
54
68
  this.tokens.links = Object.create(null);
55
- this.options = options || defaults;
56
- this.options.tokenizer = this.options.tokenizer || new Tokenizer();
69
+ this.options = options || _defaults;
70
+ this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
57
71
  this.tokenizer = this.options.tokenizer;
58
72
  this.tokenizer.options = this.options;
59
73
  this.tokenizer.lexer = this;
@@ -86,7 +100,7 @@ export class Lexer {
86
100
  /**
87
101
  * Expose Rules
88
102
  */
89
- static get rules() {
103
+ static get rules(): Rules {
90
104
  return {
91
105
  block,
92
106
  inline
@@ -96,23 +110,23 @@ export class Lexer {
96
110
  /**
97
111
  * Static Lex Method
98
112
  */
99
- static lex(src, options) {
100
- const lexer = new Lexer(options);
113
+ static lex(src: string, options?: MarkedOptions) {
114
+ const lexer = new _Lexer(options);
101
115
  return lexer.lex(src);
102
116
  }
103
117
 
104
118
  /**
105
119
  * Static Lex Inline Method
106
120
  */
107
- static lexInline(src, options) {
108
- const lexer = new Lexer(options);
121
+ static lexInline(src: string, options?: MarkedOptions) {
122
+ const lexer = new _Lexer(options);
109
123
  return lexer.inlineTokens(src);
110
124
  }
111
125
 
112
126
  /**
113
127
  * Preprocessing
114
128
  */
115
- lex(src) {
129
+ lex(src: string) {
116
130
  src = src
117
131
  .replace(/\r\n|\r/g, '\n');
118
132
 
@@ -129,7 +143,9 @@ export class Lexer {
129
143
  /**
130
144
  * Lexing
131
145
  */
132
- blockTokens(src, tokens = []) {
146
+ blockTokens(src: string, tokens?: Token[]): Token[];
147
+ blockTokens(src: string, tokens?: TokensList): TokensList;
148
+ blockTokens(src: string, tokens: Token[] = []) {
133
149
  if (this.options.pedantic) {
134
150
  src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
135
151
  } else {
@@ -143,7 +159,7 @@ export class Lexer {
143
159
  while (src) {
144
160
  if (this.options.extensions
145
161
  && this.options.extensions.block
146
- && this.options.extensions.block.some((extTokenizer) => {
162
+ && this.options.extensions.block.some((extTokenizer: TokenizerExtension['tokenizer']) => {
147
163
  if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
148
164
  src = src.substring(token.raw.length);
149
165
  tokens.push(token);
@@ -262,7 +278,7 @@ export class Lexer {
262
278
  let startIndex = Infinity;
263
279
  const tempSrc = src.slice(1);
264
280
  let tempStart;
265
- this.options.extensions.startBlock.forEach(function(getStartIndex) {
281
+ this.options.extensions.startBlock.forEach((getStartIndex) => {
266
282
  tempStart = getStartIndex.call({ lexer: this }, tempSrc);
267
283
  if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
268
284
  });
@@ -315,7 +331,7 @@ export class Lexer {
315
331
  return tokens;
316
332
  }
317
333
 
318
- inline(src, tokens = []) {
334
+ inline(src: string, tokens: Token[] = []) {
319
335
  this.inlineQueue.push({ src, tokens });
320
336
  return tokens;
321
337
  }
@@ -323,7 +339,7 @@ export class Lexer {
323
339
  /**
324
340
  * Lexing/Compiling
325
341
  */
326
- inlineTokens(src, tokens = []) {
342
+ inlineTokens(src: string, tokens: Token[] = []): Token[] {
327
343
  let token, lastToken, cutSrc;
328
344
 
329
345
  // String with links masked to avoid interference with em and strong
@@ -461,7 +477,7 @@ export class Lexer {
461
477
  let startIndex = Infinity;
462
478
  const tempSrc = src.slice(1);
463
479
  let tempStart;
464
- this.options.extensions.startInline.forEach(function(getStartIndex) {
480
+ this.options.extensions.startInline.forEach((getStartIndex) => {
465
481
  tempStart = getStartIndex.call({ lexer: this }, tempSrc);
466
482
  if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
467
483
  });
@@ -0,0 +1,212 @@
1
+ import type { Token, Tokens, TokensList } from './Tokens.ts';
2
+ import { _Parser } from './Parser.ts';
3
+ import { _Lexer } from './Lexer.ts';
4
+ import { _Renderer } from './Renderer.ts';
5
+ import { _Tokenizer } from './Tokenizer.ts';
6
+
7
+ export interface SluggerOptions {
8
+ /** Generates the next unique slug without updating the internal accumulator. */
9
+ dryrun?: boolean;
10
+ }
11
+
12
+ export interface TokenizerThis {
13
+ lexer: _Lexer;
14
+ }
15
+
16
+ export interface TokenizerExtension {
17
+ name: string;
18
+ level: 'block' | 'inline';
19
+ start?: ((this: TokenizerThis, src: string) => number | void) | undefined;
20
+ tokenizer: (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | void;
21
+ childTokens?: string[] | undefined;
22
+ }
23
+
24
+ export interface RendererThis {
25
+ parser: _Parser;
26
+ }
27
+
28
+ export interface RendererExtension {
29
+ name: string;
30
+ renderer: (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
31
+ }
32
+
33
+ export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
34
+
35
+ type RendererApi = Omit<_Renderer, 'constructor' | 'options'>;
36
+ type RendererObject = {
37
+ [K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false
38
+ };
39
+
40
+ type TokenizerApi = Omit<_Tokenizer, 'constructor' | 'options' | 'rules' | 'lexer'>;
41
+ type TokenizerObject = {
42
+ [K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false
43
+ };
44
+
45
+ export interface MarkedExtension {
46
+ /**
47
+ * True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
48
+ */
49
+ async?: boolean;
50
+
51
+ /**
52
+ * A prefix URL for any relative link.
53
+ * @deprecated Deprecated in v5.0.0 use marked-base-url to prefix url for any relative link.
54
+ */
55
+ baseUrl?: string | undefined | null;
56
+
57
+ /**
58
+ * Enable GFM line breaks. This option requires the gfm option to be true.
59
+ */
60
+ breaks?: boolean | undefined;
61
+
62
+ /**
63
+ * Add tokenizers and renderers to marked
64
+ */
65
+ extensions?:
66
+ | TokenizerAndRendererExtension[]
67
+ | undefined | null;
68
+
69
+ /**
70
+ * Enable GitHub flavored markdown.
71
+ */
72
+ gfm?: boolean | undefined;
73
+
74
+ /**
75
+ * Include an id attribute when emitting headings.
76
+ * @deprecated Deprecated in v5.0.0 use marked-gfm-heading-id to include an id attribute when emitting headings (h1, h2, h3, etc).
77
+ */
78
+ headerIds?: boolean | undefined;
79
+
80
+ /**
81
+ * Set the prefix for header tag ids.
82
+ * @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).
83
+ */
84
+ headerPrefix?: string | undefined;
85
+
86
+ /**
87
+ * A function to highlight code blocks. The function can either be
88
+ * synchronous (returning a string) or asynchronous (callback invoked
89
+ * with an error if any occurred during highlighting and a string
90
+ * if highlighting was successful)
91
+ * @deprecated Deprecated in v5.0.0 use marked-highlight to add highlighting to code blocks.
92
+ */
93
+ highlight?: ((code: string, lang: string | undefined, callback?: (error: Error, code?: string) => void) => string | void) | null;
94
+
95
+ /**
96
+ * Hooks are methods that hook into some part of marked.
97
+ * preprocess is called to process markdown before sending it to marked.
98
+ * postprocess is called to process html after marked has finished parsing.
99
+ */
100
+ hooks?: {
101
+ preprocess: (markdown: string) => string,
102
+ postprocess: (html: string | undefined) => string | undefined,
103
+ // eslint-disable-next-line no-use-before-define
104
+ options?: MarkedOptions
105
+ } | null;
106
+
107
+ /**
108
+ * Set the prefix for code block classes.
109
+ * @deprecated Deprecated in v5.0.0 use marked-highlight to prefix the className in a <code> block. Useful for syntax highlighting.
110
+ */
111
+ langPrefix?: string | undefined;
112
+
113
+ /**
114
+ * Mangle autolinks (<email@domain.com>).
115
+ * @deprecated Deprecated in v5.0.0 use marked-mangle to mangle email addresses.
116
+ */
117
+ mangle?: boolean | undefined;
118
+
119
+ /**
120
+ * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
121
+ */
122
+ pedantic?: boolean | undefined;
123
+
124
+ /**
125
+ * Type: object Default: new Renderer()
126
+ *
127
+ * An object containing functions to render tokens to HTML.
128
+ */
129
+ renderer?: RendererObject | undefined | null;
130
+
131
+ /**
132
+ * Sanitize the output. Ignore any HTML that has been input. If true, sanitize the HTML passed into markdownString with the sanitizer function.
133
+ * @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!
134
+ */
135
+ sanitize?: boolean | undefined;
136
+
137
+ /**
138
+ * Optionally sanitize found HTML with a sanitizer function.
139
+ * @deprecated A function to sanitize the HTML passed into markdownString.
140
+ */
141
+ sanitizer?: ((html: string) => string) | null;
142
+
143
+ /**
144
+ * Shows an HTML error message when rendering fails.
145
+ */
146
+ silent?: boolean | undefined;
147
+
148
+ /**
149
+ * Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
150
+ */
151
+ smartLists?: boolean | undefined;
152
+
153
+ /**
154
+ * Use "smart" typograhic punctuation for things like quotes and dashes.
155
+ * @deprecated Deprecated in v5.0.0 use marked-smartypants to use "smart" typographic punctuation for things like quotes and dashes.
156
+ */
157
+ smartypants?: boolean | undefined;
158
+
159
+ /**
160
+ * The tokenizer defines how to turn markdown text into tokens.
161
+ */
162
+ tokenizer?: TokenizerObject | undefined | null;
163
+
164
+ /**
165
+ * The walkTokens function gets called with every token.
166
+ * Child tokens are called before moving on to sibling tokens.
167
+ * Each token is passed by reference so updates are persisted when passed to the parser.
168
+ * The return value of the function is ignored.
169
+ */
170
+ walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
171
+ /**
172
+ * Generate closing slash for self-closing tags (<br/> instead of <br>)
173
+ * @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.
174
+ */
175
+ xhtml?: boolean | undefined;
176
+ }
177
+
178
+ export interface MarkedOptions extends Omit<MarkedExtension, 'extensions' | 'renderer' | 'tokenizer' | 'walkTokens'> {
179
+ /**
180
+ * Type: object Default: new Renderer()
181
+ *
182
+ * An object containing functions to render tokens to HTML.
183
+ */
184
+ renderer?: Omit<_Renderer, 'constructor'> | undefined | null;
185
+
186
+ /**
187
+ * The tokenizer defines how to turn markdown text into tokens.
188
+ */
189
+ tokenizer?: Omit<_Tokenizer, 'constructor'> | undefined | null;
190
+
191
+ /**
192
+ * The walkTokens function gets called with every token.
193
+ * Child tokens are called before moving on to sibling tokens.
194
+ * Each token is passed by reference so updates are persisted when passed to the parser.
195
+ * The return value of the function is ignored.
196
+ */
197
+ walkTokens?: ((token: Token) => void | Promise<void> | Array<void | Promise<void>>) | undefined | null;
198
+
199
+ /**
200
+ * Add tokenizers and renderers to marked
201
+ */
202
+ extensions?:
203
+ | (TokenizerAndRendererExtension[] & {
204
+ renderers: Record<string, (this: RendererThis, token: Tokens.Generic) => string | false | undefined>,
205
+ childTokens: Record<string, string[]>,
206
+ block: any[],
207
+ inline: any[],
208
+ startBlock: Array<(this: TokenizerThis, src: string) => number | void>,
209
+ startInline: Array<(this: TokenizerThis, src: string) => number | void>
210
+ })
211
+ | undefined | null;
212
+ }