UNPKG

34.5 kBTypeScriptView Raw
1export = Showdown;
2export as namespace showdown;
3
4/**
5 * Showdown namespace
6 *
7 * @see https://github.com/showdownjs/showdown/blob/master/src/showdown.js
8 */
9declare namespace Showdown {
10 /**
11 * Showdown event listener.
12 */
13 interface EventListener {
14 /**
15 * @param evtName - The event name.
16 * @param text - The current convert value.
17 * @param converter - The converter instance.
18 * @param options - The converter options.
19 * @param globals - A global parsed data of the current conversion.
20 * @returns Can be returned string value to change the current convert value (`text`).
21 * @example
22 * Change by returns string value.
23 * ```ts
24 * let listener: EventListener = (evtName, text, converter, options, globals) => doSome(text);
25 * ```
26 */
27 (
28 evtName: string,
29 text: string,
30 converter: Converter,
31 options: ShowdownOptions,
32 globals: ConverterGlobals,
33 // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
34 ): void | string;
35 }
36
37 interface ConverterGlobals {
38 converter?: Converter | undefined;
39 gDimensions?: {
40 width?: number | undefined;
41 height?: number | undefined;
42 } | undefined;
43 gHtmlBlocks?: string[] | undefined;
44 gHtmlMdBlocks?: string[] | undefined;
45 gHtmlSpans?: string[] | undefined;
46 gListLevel?: number | undefined;
47 gTitles?: { [key: string]: string } | undefined;
48 gUrls?: { [key: string]: string } | undefined;
49 ghCodeBlocks?: Array<{ codeblock?: string | undefined; text?: string | undefined }> | undefined;
50 hashLinkCounts?: { [key: string]: number } | undefined;
51 langExtensions?: ShowdownExtension[] | undefined;
52 metadata?: {
53 parsed?: { [key: string]: string } | undefined;
54 raw?: string | undefined;
55 format?: string | undefined;
56 } | undefined;
57 outputModifiers?: ShowdownExtension[] | undefined;
58 }
59
60 interface Extension {
61 /**
62 * Property defines the nature of said sub-extensions and can assume 2 values:
63 *
64 * * `lang` - Language extensions add new markdown syntax to showdown.
65 * * `output` - Output extensions (or modifiers) alter the HTML output generated by showdown.
66 * * `listener` - Listener extensions for listening to a conversion event.
67 */
68 type: string;
69
70 /**
71 * Event listeners functions that called on the conversion, when the `event` occurs.
72 */
73 listeners?: { [event: string]: EventListener } | undefined;
74 }
75
76 /**
77 * Regex/replace style extensions are very similar to javascript's string.replace function.
78 * Two properties are given, `regex` and `replace`.
79 *
80 * @example
81 * ```ts
82 * let myExt: RegexReplaceExtension = {
83 * type: 'lang',
84 * regex: /markdown/g,
85 * replace: 'showdown'
86 * };
87 * ```
88 */
89 interface RegexReplaceExtension extends Extension {
90 /**
91 * Should be either a string or a RegExp object.
92 *
93 * Keep in mind that, if a string is used, it will automatically be given a g modifier,
94 * that is, it is assumed to be a global replacement.
95 */
96 regex?: string | RegExp | undefined;
97
98 /**
99 * Can be either a string or a function. If replace is a string,
100 * it can use the $1 syntax for group substitution,
101 * exactly as if it were making use of string.replace (internally it does this actually).
102 */
103 replace?: any; // string | Replace
104 }
105
106 /**
107 * If you'd just like to do everything yourself,you can specify a filter property.
108 * The filter property should be a function that acts as a callback.
109 *
110 * @example
111 * ```ts
112 * let myExt: ShowdownExtension = {
113 * type: 'lang',
114 * filter: (text: string, converter: Converter) => text.replace('#', '*')
115 * };
116 * ```
117 */
118 interface FilterExtension extends Extension {
119 filter?: ((text: string, converter: Converter, options?: ConverterOptions) => string) | undefined;
120 }
121
122 /**
123 * Defines a plugin/extension
124 * Each single extension can be one of two types:
125 *
126 * + Language Extension -- Language extensions are ones that that add new markdown syntax to showdown. For example, say you wanted ^^youtube http://www.youtube.com/watch?v=oHg5SJYRHA0 to automatically render as an embedded YouTube video, that would be a language extension.
127 * + Output Modifiers -- After showdown has run, and generated HTML, an output modifier would change that HTML. For example, say you wanted to change <div class="header"> to be <header>, that would be an output modifier.
128 * + Listener Extension -- Listener extensions for listen to conversion events.
129 *
130 * Each extension can provide two combinations of interfaces for showdown.
131 *
132 * @example
133 * ```ts
134 * let myext: ShowdownExtension = {
135 * type: 'output',
136 * filter(text, converter, options) {
137 * // ... do stuff to text ...
138 * return text;
139 * },
140 * listeners: {
141 * ['lists.after'](evtName, text, converter, options, globals){
142 * // ... do stuff to text ...
143 * return text;
144 * },
145 * // ...
146 * }
147 * };
148 * ```
149 */
150 interface ShowdownExtension extends RegexReplaceExtension, FilterExtension {
151 }
152
153 /**
154 * Showdown extensions store object.
155 */
156 interface ShowdownExtensions {
157 [name: string]: ShowdownExtension[];
158 }
159
160 /**
161 * Showdown converter extensions store object.
162 */
163 interface ConverterExtensions {
164 language: ShowdownExtension[];
165 output: ShowdownExtension[];
166 }
167
168 interface Metadata {
169 [meta: string]: string;
170 }
171
172 /**
173 * Showdown options.
174 *
175 * @see https://github.com/showdownjs/showdown#valid-options
176 * @see https://github.com/showdownjs/showdown/wiki/Showdown-options
177 * @see https://github.com/showdownjs/showdown/blob/master/src/options.js
178 */
179 interface ShowdownOptions {
180 /**
181 * Omit the trailing newline in a code block.
182 * By default, showdown adds a newline before the closing tags in code blocks. By enabling this option, that newline is removed.
183 * This option affects both indented and fenced (gfm style) code blocks.
184 *
185 * @example
186 *
187 * **input**:
188 *
189 * ```md
190 * var foo = 'bar';
191 * ```
192 *
193 * **omitExtraWLInCodeBlocks** = false:
194 *
195 * ```html
196 * <code><pre>var foo = 'bar';
197 * </pre></code>
198 * ```
199 * **omitExtraWLInCodeBlocks** = true:
200 *
201 * ```html
202 * <code><pre>var foo = 'bar';</pre></code>
203 * ```
204 * @default false
205 * @since 1.0.0
206 */
207 omitExtraWLInCodeBlocks?: boolean | undefined;
208
209 /**
210 * Disable the automatic generation of header ids.
211 * Showdown generates an id for headings automatically. This is useful for linking to a specific header.
212 * This behavior, however, can be disabled with this option.
213 *
214 * @example
215 * **input**:
216 *
217 * ```md
218 * # This is a header
219 * ```
220 *
221 * **noHeaderId** = false
222 *
223 * ```html
224 * <h1 id="thisisaheader">This is a header</h1>
225 * ```
226 *
227 * **noHeaderId** = true
228 *
229 * ```html
230 * <h1>This is a header</h1>
231 * ```
232 * @default false
233 * @since 1.1.0
234 */
235 noHeaderId?: boolean | undefined;
236
237 /**
238 * Use text in curly braces as header id.
239 *
240 * @example
241 * ```md
242 * ## Sample header {real-id} will use real-id as id
243 * ```
244 * @default false
245 * @since 1.7.0
246 */
247 customizedHeaderId?: boolean | undefined;
248
249 /**
250 * Generate header ids compatible with github style (spaces are replaced
251 * with dashes and a bunch of non alphanumeric chars are removed).
252 *
253 * @example
254 * **input**:
255 *
256 * ```md
257 * # This is a header with @#$%
258 * ```
259 *
260 * **ghCompatibleHeaderId** = false
261 *
262 * ```html
263 * <h1 id="thisisaheader">This is a header</h1>
264 * ```
265 *
266 * **ghCompatibleHeaderId** = true
267 *
268 * ```html
269 * <h1 id="this-is-a-header-with-">This is a header with @#$%</h1>
270 * ```
271 * @default false
272 * @since 1.5.5
273 */
274 ghCompatibleHeaderId?: boolean | undefined;
275
276 /**
277 * Add a prefix to the generated header ids.
278 * Passing a string will prefix that string to the header id.
279 * Setting to true will add a generic 'section' prefix.
280 *
281 * @default false
282 * @since 1.0.0
283 */
284 prefixHeaderId?: string | boolean | undefined;
285
286 /**
287 * Setting this option to true will prevent showdown from modifying the prefix.
288 * This might result in malformed IDs (if, for instance, the " char is used in the prefix).
289 * Has no effect if prefixHeaderId is set to false.
290 *
291 * @default false
292 * @since 1.7.3
293 */
294 rawPrefixHeaderId?: boolean | undefined;
295
296 /**
297 * Remove only spaces, ' and " from generated header ids (including prefixes),
298 * replacing them with dashes (-).
299 * WARNING: This might result in malformed ids.
300 *
301 * @default false
302 * @since 1.7.3
303 */
304 rawHeaderId?: boolean | undefined;
305
306 /**
307 * Enable support for setting image dimensions from within markdown syntax.
308 *
309 * @example
310 * ```md
311 * ![foo](foo.jpg =100x80) simple, assumes units are in px
312 * ![bar](bar.jpg =100x*) sets the height to "auto"
313 * ![baz](baz.jpg =80%x5em) Image with width of 80% and height of 5em
314 * ```
315 * @default false
316 * @since 1.1.0
317 */
318 parseImgDimensions?: boolean | undefined;
319
320 /**
321 * Set the header starting level. For instance, setting this to 3 means that
322 *
323 * @example
324 * **input**:
325 *
326 * ```md
327 * # header
328 * ```
329 *
330 * **headerLevelStart** = 1
331 *
332 * ```html
333 * <h1>header</h1>
334 * ```
335 *
336 * **headerLevelStart** = 3
337 *
338 * ```html
339 * <h3>header</h3>
340 * ```
341 * @default 1
342 * @since 1.1.0
343 */
344 headerLevelStart?: number | undefined;
345
346 /**
347 * Turning this option on will enable automatic linking to urls.
348 *
349 * @example
350 * **input**:
351 *
352 * ```md
353 * some text www.google.com
354 * ```
355 *
356 * **simplifiedAutoLink** = false
357 *
358 * ```html
359 * <p>some text www.google.com</p>
360 * ```
361 *
362 * **simplifiedAutoLink** = true
363 *
364 * ```html
365 * <p>some text <a href="www.google.com">www.google.com</a></p>
366 * ```
367 * @default false
368 * @since 1.2.0
369 */
370 simplifiedAutoLink?: boolean | undefined;
371
372 /**
373 * @deprecated https://github.com/showdownjs/showdown/commit/d3ebff7ef0cde5abfc3874463946d5297fc82e78
374 *
375 * This option excludes trailing punctuation from autolinking urls.
376 * Punctuation excluded: . ! ? ( ).
377 *
378 * @remarks This option only applies to links generated by {@link Showdown.ShowdownOptions.simplifiedAutoLink}.
379 * @example
380 * **input**:
381 *
382 * ```md
383 * check this link www.google.com.
384 * ```
385 *
386 * **excludeTrailingPunctuationFromURLs** = false
387 *
388 * ```html
389 * <p>check this link <a href="www.google.com">www.google.com.</a></p>
390 * ```
391 *
392 * **excludeTrailingPunctuationFromURLs** = true
393 *
394 * ```html
395 * <p>check this link <a href="www.google.com">www.google.com</a>.</p>
396 * ```
397 * @default false
398 * @since 1.5.1
399 */
400 excludeTrailingPunctuationFromURLs?: boolean | undefined;
401
402 /**
403 * Turning this on will stop showdown from interpreting underscores in the middle of
404 * words as <em> and <strong> and instead treat them as literal underscores.
405 *
406 * @example
407 * **input**:
408 *
409 * ```md
410 * some text with__underscores__in middle
411 * ```
412 *
413 * **literalMidWordUnderscores** = false
414 *
415 * ```html
416 * <p>some text with<strong>underscores</strong>in middle</p>
417 * ```
418 *
419 * **literalMidWordUnderscores** = true
420 *
421 * ```html
422 * <p>some text with__underscores__in middle</p>
423 * ```
424 * @default false
425 * @since 1.2.0
426 */
427 literalMidWordUnderscores?: boolean | undefined;
428
429 /**
430 * Enable support for strikethrough syntax.
431 *
432 * @example
433 * **syntax**:
434 *
435 * ```md
436 * ~~strikethrough~~
437 * ```
438 *
439 * ```html
440 * <del>strikethrough</del>
441 * ```
442 * @default false
443 * @since 1.2.0
444 */
445 strikethrough?: boolean | undefined;
446
447 /**
448 * Enable support for tables syntax.
449 *
450 * @example
451 * **syntax**:
452 *
453 * ```md
454 * | h1 | h2 | h3 |
455 * |:------|:-------:|--------:|
456 * | 100 | [a][1] | ![b][2] |
457 * | *foo* | **bar** | ~~baz~~ |
458 * ```
459 * @default false
460 * @since 1.2.0
461 */
462 tables?: boolean | undefined;
463
464 /**
465 * If enabled adds an id property to table headers tags.
466 *
467 * @remarks This options only applies if **[tables][]** is enabled.
468 * @default false
469 * @since 1.2.0
470 */
471 tablesHeaderId?: boolean | undefined;
472
473 /**
474 * Enable support for GFM code block style syntax (fenced codeblocks).
475 *
476 * @example
477 * **syntax**:
478 *
479 * ```md
480 * some code here
481 * ```
482 * @default true
483 * @since 1.2.0
484 */
485 ghCodeBlocks?: boolean | undefined;
486
487 /**
488 * Enable support for GFM takslists.
489 *
490 * @example
491 * **syntax**:
492 *
493 * ```md
494 * - [x] This task is done
495 * - [ ] This is still pending
496 * ```
497 * @default false
498 * @since 1.2.0
499 */
500 tasklists?: boolean | undefined;
501
502 /**
503 * Prevents weird effects in live previews due to incomplete input.
504 *
505 * @example
506 * ![awkward effect](http://i.imgur.com/YQ9iHTL.gif)
507 * You can prevent this by enabling this option.
508 * @default false
509 */
510 smoothLivePreview?: boolean | undefined;
511
512 /**
513 * Tries to smartly fix indentation problems related to es6 template
514 * strings in the midst of indented code.
515 *
516 * @default false
517 * @since 1.4.2
518 */
519 smartIndentationFix?: boolean | undefined;
520
521 /**
522 * Disables the requirement of indenting sublists by 4 spaces for them to be nested,
523 * effectively reverting to the old behavior where 2 or 3 spaces were enough.
524 *
525 * @example
526 * **input**:
527 *
528 * ```md
529 * - one
530 * - two
531 *
532 * ...
533 *
534 * - one
535 * - two
536 * ```
537 *
538 * **disableForced4SpacesIndentedSublists** = false
539 *
540 * ```html
541 * <ul>
542 * <li>one</li>
543 * <li>two</li>
544 * </ul>
545 * <p>...</p>
546 * <ul>
547 * <li>one
548 * <ul>
549 * <li>two</li>
550 * </ul>
551 * </li>
552 * </ul>
553 * ```
554 *
555 * **disableForced4SpacesIndentedSublists** = true
556 *
557 * ```html
558 * <ul>
559 * <li>one
560 * <ul>
561 * <li>two</li>
562 * </ul>
563 * </li>
564 * </ul>
565 * <p>...</p>
566 * <ul>
567 * <li>one
568 * <ul>
569 * <li>two</li>
570 * </ul>
571 * </li>
572 * </ul>
573 * ```
574 * @default false
575 * @since 1.5.0
576 */
577 disableForced4SpacesIndentedSublists?: boolean | undefined;
578
579 /**
580 * Parses line breaks as like GitHub does, without needing 2 spaces at the end of the line.
581 *
582 * @example
583 * **input**:
584 *
585 * ```md
586 * a line
587 * wrapped in two
588 * ```
589 *
590 * **simpleLineBreaks** = false
591 *
592 * ```html
593 * <p>a line
594 * wrapped in two</p>
595 * ```
596 *
597 * **simpleLineBreaks** = true
598 *
599 * ```html
600 * <p>a line<br>
601 * wrapped in two</p>
602 * ```
603 * @default false
604 * @since 1.5.1
605 */
606 simpleLineBreaks?: boolean | undefined;
607
608 /**
609 * Makes adding a space between # and the header text mandatory.
610 *
611 * @example
612 * **input**:
613 *
614 * ```md
615 * #header
616 * ```
617 *
618 * **requireSpaceBeforeHeadingText** = false
619 *
620 * ```html
621 * <h1 id="header">header</h1>
622 * ```
623 *
624 * **simpleLineBreaks** = true
625 *
626 * ```html
627 * <p>#header</p>
628 * ```
629 *
630 * @default false
631 * @since 1.5.3
632 */
633 requireSpaceBeforeHeadingText?: boolean | undefined;
634
635 /**
636 * Enables support for github @mentions, which links to the github profile page of the username mentioned.
637 *
638 * @example
639 * **input**:
640 *
641 * ```md
642 * hello there @tivie
643 * ```
644 *
645 * **ghMentions** = false
646 *
647 * ```html
648 * <p>hello there @tivie</p>
649 * ```
650 *
651 * **ghMentions** = true
652 *
653 * ```html
654 * <p>hello there <a href="https://www.github.com/tivie>@tivie</a></p>
655 * ```
656 * @default false
657 * @since 1.6.0
658 */
659 ghMentions?: boolean | undefined;
660
661 /**
662 * Changes the link generated by @mentions. `{u}` is replaced by the text of the mentions. Only applies if **[ghMentions][]** is enabled.
663 *
664 * @example
665 * **input**:
666 *
667 * ```md
668 * hello there @tivie
669 * ```
670 *
671 * **ghMentionsLink** = https://github.com/{u}
672 *
673 * ```html
674 * <p>hello there <a href="https://www.github.com/tivie>@tivie</a></p>
675 * ```
676 *
677 * **ghMentionsLink** = http://mysite.com/{u}/profile
678 *
679 * ```html
680 * <p>hello there <a href="//mysite.com/tivie/profile">@tivie</a></p>
681 * ```
682 * @default https://github.com/{u}
683 * @since 1.6.2
684 */
685 ghMentionsLink?: string | undefined;
686
687 /**
688 * Enables e-mail addresses encoding through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities.
689 *
690 * @remarks Prior to version 1.6.1, emails would always be obfuscated through dec and hex encoding.
691 * @example
692 * **input**:
693 *
694 * ```
695 * <myself@example.com>
696 * ```
697 *
698 * **encodeEmails** = false
699 *
700 * ```html
701 * <a href="mailto:myself@example.com">myself@example.com</a>
702 * ```
703 *
704 * **encodeEmails** = true
705 *
706 * ```html
707 * <a href="&#109;&#97;&#105;&#108;t&#x6f;&#x3a;&#109;&#x79;s&#x65;&#x6c;&#102;&#64;&#x65;xa&#109;&#112;&#108;&#101;&#x2e;c&#x6f;&#109;">&#x6d;&#121;s&#101;&#108;f&#x40;&#x65;&#120;a&#x6d;&#x70;&#108;&#x65;&#x2e;&#99;&#x6f;&#109;</a>
708 * ```
709 * @default true
710 * @since 1.6.1
711 */
712 encodeEmails?: boolean | undefined;
713
714 /**
715 * Open all links in new windows (by adding the attribute target="_blank" to <a> tags).
716 *
717 * @example
718 * **input**:
719 *
720 * ```md
721 * [Showdown](http://showdownjs.com)
722 * ```
723 *
724 * **openLinksInNewWindow** = false
725 * ```html
726 * <p><a href="http://showdownjs.com">Showdown</a></p>
727 * ```
728 *
729 * **openLinksInNewWindow** = true
730 * ```html
731 * <p><a href="http://showdownjs.com" target="_blank">Showdown</a></p>
732 * ```
733 * @default false
734 * @since 1.7.0
735 */
736 openLinksInNewWindow?: boolean | undefined;
737
738 /**
739 * Support for HTML Tag escaping.
740 *
741 * @example
742 * **input**:
743 *
744 * ```md
745 * \<div>foo\</div>.
746 * ```
747 *
748 * **backslashEscapesHTMLTags** = false
749 * ```html
750 * <p>\<div>foo\</div></p>
751 * ```
752 *
753 * **backslashEscapesHTMLTags** = true
754 * ```html
755 * <p>&lt;div&gt;foo&lt;/div&gt;</p>
756 * ```
757 * @default false
758 * @since 1.7.2
759 */
760 backslashEscapesHTMLTags?: boolean | undefined;
761
762 /**
763 * Enable emoji support.
764 *
765 * @example
766 * ```md
767 * this is a :smile: emoji
768 * ```
769 * @default false
770 * @see https://github.com/showdownjs/showdown/wiki/Emojis
771 * @since 1.8.0
772 */
773 emoji?: boolean | undefined;
774
775 /**
776 * Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled,
777 * underscores no longer parses into `<em>` and `<strong>`
778 *
779 * @example
780 * **input**:
781 *
782 * ```md
783 * __underline word__
784 * ```
785 *
786 * **underline** = false
787 * ```html
788 * <p><strong>underlined word</strong></p>
789 * ```
790 *
791 * **underline** = true
792 * ```html
793 * <p><u>underlined word</u></p>
794 * ```
795 * @default false
796 * @since 1.8.0
797 */
798 underline?: boolean | undefined;
799
800 /**
801 * Replaces three dots with the ellipsis unicode character.
802 * @default true
803 */
804 ellipsis?: boolean | undefined;
805
806 /**
807 * Outputs a complete html document, including <html>, <head> and <body> tags' instead of an HTML fragment.
808 *
809 * @example
810 * **input**:
811 *
812 * ```md
813 * # Showdown
814 * ```
815 *
816 * **completeHTMLDocument** = false
817 * ```html
818 * <p><strong>Showdown</strong></p>
819 * ```
820 *
821 * **completeHTMLDocument** = true
822 * ```html
823 * <!DOCTYPE HTML>
824 * <html>
825 * <head>
826 * <meta charset="utf-8">
827 * </head>
828 * <body>
829 * <p><strong>Showdown</strong></p>
830 * </body>
831 * </html>
832 * ```
833 * @default false
834 * @since 1.8.5
835 */
836 completeHTMLDocument?: boolean | undefined;
837
838 /**
839 * Enable support for document metadata (defined at the top of the document
840 * between `«««` and `»»»` or between `---` and `---`).
841 *
842 * @example
843 * ```js
844 * var conv = new showdown.Converter({metadata: true});
845 * var html = conv.makeHtml(someMd);
846 * var metadata = conv.getMetadata(); // returns an object with the document metadata
847 * ```
848 * @default false
849 * @since 1.8.5
850 */
851 metadata?: boolean | undefined;
852
853 /**
854 * Split adjacent blockquote blocks.
855 *
856 * @since 1.8.6
857 */
858 splitAdjacentBlockquotes?: boolean | undefined;
859
860 /**
861 * For custom options {extension, subParser} And also an out-of-date definitions
862 */
863 [key: string]: any;
864 }
865
866 interface ConverterOptions extends ShowdownOptions {
867 /**
868 * Add extensions to the new converter can be showdown extensions or "global" extensions name.
869 */
870 extensions?:
871 | Array<(() => ShowdownExtension[] | ShowdownExtension) | ShowdownExtension[] | ShowdownExtension | string>
872 | undefined;
873 }
874
875 /**
876 * Showdown Flavor names.
877 */
878 type Flavor = "github" | "original" | "ghost" | "vanilla" | "allOn";
879
880 /**
881 * Showdown option description.
882 */
883 interface ShowdownOptionDescription {
884 /**
885 * The default value of option.
886 */
887 defaultValue?: boolean | undefined;
888 /**
889 * The description of the option.
890 */
891 description?: string | undefined;
892 /**
893 * The type of the option value.
894 */
895 type?: "boolean" | "string" | "integer" | undefined;
896 }
897
898 /**
899 * Showdown options schema.
900 */
901 interface ShowdownOptionsSchema {
902 [key: string]: ShowdownOptionDescription;
903 }
904
905 /**
906 * Showdown subParser.
907 */
908 type SubParser = (...args: any[]) => string;
909
910 /**
911 * Showdown Converter prototype.
912 *
913 * @see https://github.com/showdownjs/showdown/blob/master/src/converter.js
914 */
915 interface Converter {
916 /**
917 * Listen to an event.
918 *
919 * @param name - The event name.
920 * @param callback - The function that will be called when the event occurs.
921 * @throws Throws if the type of `name` is not string.
922 * @throws Throws if the type of `callback` is not function.
923 * @example
924 * ```ts
925 * let converter: Converter = new Converter();
926 * converter
927 * .listen('hashBlock.before', (evtName, text, converter, options, globals) => {
928 * // ... do stuff to text ...
929 * return text;
930 * })
931 * .makeHtml('...');
932 * ```
933 */
934 listen(name: string, callback: EventListener): Converter;
935
936 /**
937 * Converts a markdown string into HTML string.
938 *
939 * @param text - The input text (markdown).
940 * @return The output HTML.
941 */
942 makeHtml(text: string): string;
943
944 /**
945 * Converts an HTML string into a markdown string.
946 *
947 * @param src - The input text (HTML)
948 * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used.
949 * @returns The output markdown.
950 */
951 makeMarkdown(src: string, HTMLParser?: HTMLDocument): string;
952
953 /**
954 * Setting a "local" option only affects the specified Converter object.
955 *
956 * @param key - The key of the option.
957 * @param value - The value of the option.
958 */
959 setOption(key: string, value: any): void;
960
961 /**
962 * Get the option of this Converter instance.
963 *
964 * @param key - The key of the option.
965 * @returns Returns the value of the given `key`.
966 */
967 getOption(key: string): any;
968
969 /**
970 * Get the options of this Converter instance.
971 *
972 * @returns Returns the current convertor options object.
973 */
974 getOptions(): ShowdownOptions;
975
976 /**
977 * Add extension to THIS converter.
978 *
979 * @param extension - The new extension to add.
980 * @param name - The extension name.
981 */
982 addExtension(
983 extension: (() => ShowdownExtension[] | ShowdownExtension) | ShowdownExtension[] | ShowdownExtension,
984 name?: string,
985 ): void;
986
987 /**
988 * Use a global registered extension with THIS converter.
989 *
990 * @param extensionName - Name of the previously registered extension.
991 */
992 useExtension(extensionName: string): void;
993
994 /**
995 * Set a "local" flavor for THIS Converter instance.
996 *
997 * @param flavor - The flavor name.
998 */
999 setFlavor(name: Flavor): void;
1000
1001 /**
1002 * Get the "local" currently set flavor of this converter.
1003 *
1004 * @returns Returns string flavor name.
1005 */
1006 getFlavor(): Flavor;
1007
1008 /**
1009 * Remove an extension from THIS converter.
1010 *
1011 * @remarks This is a costly operation. It's better to initialize a new converter.
1012 * and specify the extensions you wish to use.
1013 * @param extensions - The extensions to remove.
1014 */
1015 removeExtension(extensions: ShowdownExtension[] | ShowdownExtension): void;
1016
1017 /**
1018 * Get all extensions.
1019 *
1020 * @return all extensions.
1021 */
1022 getAllExtensions(): ConverterExtensions;
1023
1024 /**
1025 * Get the metadata of the previously parsed document.
1026 *
1027 * @param raw - If to returns Row or Metadata.
1028 * @returns Returns Row if `row` is `true`, otherwise Metadata.
1029 */
1030 getMetadata(raw?: boolean): string | Metadata;
1031
1032 /**
1033 * Get the metadata format of the previously parsed document.
1034 *
1035 * @returns Returns the metadata format.
1036 */
1037 getMetadataFormat(): string;
1038 }
1039
1040 interface ConverterStatic {
1041 /**
1042 * @param converterOptions - Configuration object, describes which extensions to apply.
1043 */
1044 new(converterOptions?: ConverterOptions): Converter;
1045 }
1046
1047 /**
1048 * Helper Interface
1049 */
1050 interface Helper {
1051 replaceRecursiveRegExp(...args: any[]): string;
1052 [key: string]: (...args: any[]) => any;
1053 }
1054
1055 /**
1056 * Constructor function for a Converter.
1057 */
1058 var Converter: ConverterStatic;
1059
1060 /**
1061 * Showdown helper.
1062 */
1063 var helper: Helper;
1064
1065 /**
1066 * Showdown extensions.
1067 */
1068 var extensions: ShowdownExtensions;
1069
1070 /**
1071 * Setting a "global" option affects all instances of showdown.
1072 *
1073 * @param key - the option key.
1074 * @param value - the option value.
1075 */
1076 function setOption(key: string, value: any): typeof Showdown;
1077
1078 /**
1079 * Get a "global" option.
1080 *
1081 * @param key - the option key.
1082 * @returns Returns the value of the given `key`.
1083 */
1084 function getOption(key: string): any;
1085
1086 /**
1087 * Get the "global" options.
1088 *
1089 * @returns Returns a options object.
1090 */
1091 function getOptions(): ShowdownOptions;
1092
1093 /**
1094 * Reset "global" options to the default values.
1095 */
1096 function resetOptions(): void;
1097
1098 /**
1099 * Setting a "global" flavor affects all instances of showdown.
1100 *
1101 * @param name - The flavor name.
1102 */
1103 function setFlavor(name: Flavor): void;
1104
1105 /**
1106 * Get the "global" currently set flavor.
1107 *
1108 * @returns Returns string flavor name.
1109 */
1110 function getFlavor(): Flavor;
1111
1112 /**
1113 * Get the options of a specified flavor. Returns undefined if the flavor was not found.
1114 *
1115 * @param name - Name of the flavor.
1116 * @returns Returns options object of the given flavor `name`.
1117 */
1118 function getFlavorOptions(name: Flavor): ShowdownOptions | undefined;
1119
1120 /**
1121 * Get the default options.
1122 *
1123 * @param [simple=true] - If to returns the default showdown options or the showdown options schema.
1124 * @returns Returns the options schema if `simple` is `false`, otherwise the default showdown options.
1125 */
1126 function getDefaultOptions(simple?: boolean): ShowdownOptionsSchema | ShowdownOptions;
1127
1128 /**
1129 * Get a registered subParser.
1130 *
1131 * @param name - The parser name.
1132 * @returns Returns the parser of the given `name`.
1133 * @throws Throws if `name` is not of type string.
1134 * @throws Throws if the parser is not exists.
1135 */
1136 function subParser(name: string): SubParser;
1137
1138 /**
1139 * Register a subParser.
1140 *
1141 * @param name - The name of the new parser.
1142 * @param func - The handler function of the new parser.
1143 * @throws Throws if `name` is not of type string.
1144 */
1145 function subParser(name: string, func: SubParser): void;
1146
1147 /**
1148 * Get a registered extension.
1149 *
1150 * @param name - The extension name.
1151 * @returns Returns the extension of the given `name`.
1152 * @throws Throws if `name` is not of type string.
1153 * @throws Throws if the extension is not exists.
1154 */
1155 function extension(name: string): ShowdownExtension[];
1156 /**
1157 * Register a extension.
1158 *
1159 * @param name - The name of the new extension.
1160 * @param ext - The extension.
1161 * @throws Throws if `name` is not of type string.
1162 */
1163 function extension(
1164 name: string,
1165 ext: (() => ShowdownExtension[] | ShowdownExtension) | ShowdownExtension[] | ShowdownExtension,
1166 ): void;
1167
1168 /**
1169 * Get the "global" extensions.
1170 *
1171 * @return Returns all extensions.
1172 */
1173 function getAllExtensions(): ShowdownExtensions;
1174
1175 /**
1176 * Remove an extension.
1177 *
1178 * @param name - The extension name.
1179 */
1180 function removeExtension(name: string): void;
1181
1182 /**
1183 * Removes all extensions.
1184 */
1185 function resetExtensions(): void;
1186
1187 /**
1188 * Checks if the given `ext` is a valid showdown extension.
1189 *
1190 * @param ext - The extension to checks.
1191 * @returns Returns `true` if the extension is valid showdown extension, otherwise `false`.
1192 */
1193 function validateExtension(ext: ShowdownExtension[] | ShowdownExtension): boolean;
1194}
1195
\No newline at end of file