| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189 |
- // Type definitions for Showdown 1.9.0
- // Project: https://github.com/showdownjs/showdown
- // Definitions by: Hamed Baatour <https://github.com/hamedbaatour>,
- // cbowdon <https://github.com/cbowdon>,
- // Pei-Tang Huang <https://github.com/tan9>,
- // Ariel-Saldana <https://github.com/arielsaldana>,
- // Yisrael Eliav <https://github.com/yisraelx>
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
- export = Showdown;
- export as namespace showdown;
- /**
- * Showdown namespace
- *
- * @see https://github.com/showdownjs/showdown/blob/master/src/showdown.js
- */
- declare namespace Showdown {
- /**
- * Showdown event listener.
- */
- interface EventListener {
- /**
- * @param evtName - The event name.
- * @param text - The current convert value.
- * @param converter - The converter instance.
- * @param options - The converter options.
- * @param globals - A global parsed data of the current conversion.
- * @returns Can be returned string value to change the current convert value (`text`).
- * @example
- * Change by returns string value.
- * ```ts
- * let listener: EventListener = (evtName, text, converter, options, globals) => doSome(text);
- * ```
- */
- (evtName: string, text: string, converter: Converter, options: ShowdownOptions, globals: ConverterGlobals): void | string;
- }
- interface ConverterGlobals {
- converter?: Converter;
- gDimensions?: {
- width?: number;
- height?: number;
- };
- gHtmlBlocks?: string[];
- gHtmlMdBlocks?: string[];
- gHtmlSpans?: string[];
- gListLevel?: number;
- gTitles?: {[key: string]: string};
- gUrls?: {[key: string]: string};
- ghCodeBlocks?: {codeblock?: string, text?: string}[];
- hashLinkCounts?: {[key: string]: number};
- langExtensions?: ShowdownExtension[];
- metadata?: {
- parsed?: {[key: string]: string};
- raw?: string;
- format?: string;
- };
- outputModifiers?: ShowdownExtension[];
- }
- interface Extension {
- /**
- * Property defines the nature of said sub-extensions and can assume 2 values:
- *
- * * `lang` - Language extensions add new markdown syntax to showdown.
- * * `output` - Output extensions (or modifiers) alter the HTML output generated by showdown.
- * * `listener` - Listener extensions for listening to a conversion event.
- */
- type: string;
- /**
- * Event listeners functions that called on the conversion, when the `event` occurs.
- */
- listeners?: {[event: string]: EventListener}
- }
- /**
- * Regex/replace style extensions are very similar to javascript's string.replace function.
- * Two properties are given, `regex` and `replace`.
- *
- * @example
- * ```ts
- * let myExt: RegexReplaceExtension = {
- * type: 'lang',
- * regex: /markdown/g,
- * replace: 'showdown'
- * };
- * ```
- */
- interface RegexReplaceExtension extends Extension {
- /**
- * Should be either a string or a RegExp object.
- *
- * Keep in mind that, if a string is used, it will automatically be given a g modifier,
- * that is, it is assumed to be a global replacement.
- */
- regex?: string | RegExp;
- /**
- * Can be either a string or a function. If replace is a string,
- * it can use the $1 syntax for group substitution,
- * exactly as if it were making use of string.replace (internally it does this actually).
- */
- replace?: any; // string | Replace
- }
- /**
- * If you'd just like to do everything yourself,you can specify a filter property.
- * The filter property should be a function that acts as a callback.
- *
- * @example
- * ```ts
- * let myExt: ShowdownExtension = {
- * type: 'lang',
- * filter: (text: string, converter: Converter) => text.replace('#', '*')
- * };
- * ```
- */
- interface FilterExtension extends Extension {
- filter?: (text: string, converter: Converter, options?: ConverterOptions) => string;
- }
- /**
- * Defines a plugin/extension
- * Each single extension can be one of two types:
- *
- * + 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.
- * + 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.
- * + Listener Extension -- Listener extensions for listen to conversion events.
- *
- * Each extension can provide two combinations of interfaces for showdown.
- *
- * @example
- * ```ts
- * let myext: ShowdownExtension = {
- * type: 'output',
- * filter(text, converter, options) {
- * // ... do stuff to text ...
- * return text;
- * },
- * listeners: {
- * ['lists.after'](evtName, text, converter, options, globals){
- * // ... do stuff to text ...
- * return text;
- * },
- * // ...
- * }
- * };
- * ```
- */
- interface ShowdownExtension extends RegexReplaceExtension, FilterExtension {
- }
- /**
- * Showdown extensions store object.
- */
- interface ShowdownExtensions {
- [name: string]: ShowdownExtension[]
- }
- /**
- * Showdown converter extensions store object.
- */
- interface ConverterExtensions {
- language: ShowdownExtension[];
- output: ShowdownExtension[];
- }
- interface Metadata {
- [meta: string]: string;
- }
- /**
- * Showdown options.
- *
- * @see https://github.com/showdownjs/showdown#valid-options
- * @see https://github.com/showdownjs/showdown/wiki/Showdown-options
- * @see https://github.com/showdownjs/showdown/blob/master/src/options.js
- */
- interface ShowdownOptions {
- /**
- * Omit the trailing newline in a code block.
- * By default, showdown adds a newline before the closing tags in code blocks. By enabling this option, that newline is removed.
- * This option affects both indented and fenced (gfm style) code blocks.
- *
- * @example
- *
- * **input**:
- *
- * ```md
- * var foo = 'bar';
- * ```
- *
- * **omitExtraWLInCodeBlocks** = false:
- *
- * ```html
- * <code><pre>var foo = 'bar';
- * </pre></code>
- * ```
- * **omitExtraWLInCodeBlocks** = true:
- *
- * ```html
- * <code><pre>var foo = 'bar';</pre></code>
- * ```
- * @default false
- * @since 1.0.0
- */
- omitExtraWLInCodeBlocks?: boolean;
- /**
- * Disable the automatic generation of header ids.
- * Showdown generates an id for headings automatically. This is useful for linking to a specific header.
- * This behavior, however, can be disabled with this option.
- *
- * @example
- * **input**:
- *
- * ```md
- * # This is a header
- * ```
- *
- * **noHeaderId** = false
- *
- * ```html
- * <h1 id="thisisaheader">This is a header</h1>
- * ```
- *
- * **noHeaderId** = true
- *
- * ```html
- * <h1>This is a header</h1>
- * ```
- * @default false
- * @since 1.1.0
- */
- noHeaderId?: boolean;
- /**
- * Use text in curly braces as header id.
- *
- * @example
- * ```md
- * ## Sample header {real-id} will use real-id as id
- * ```
- * @default false
- * @since 1.7.0
- */
- customizedHeaderId?: boolean;
- /**
- * Generate header ids compatible with github style (spaces are replaced
- * with dashes and a bunch of non alphanumeric chars are removed).
- *
- * @example
- * **input**:
- *
- * ```md
- * # This is a header with @#$%
- * ```
- *
- * **ghCompatibleHeaderId** = false
- *
- * ```html
- * <h1 id="thisisaheader">This is a header</h1>
- * ```
- *
- * **ghCompatibleHeaderId** = true
- *
- * ```html
- * <h1 id="this-is-a-header-with-">This is a header with @#$%</h1>
- * ```
- * @default false
- * @since 1.5.5
- */
- ghCompatibleHeaderId?: boolean;
- /**
- * Add a prefix to the generated header ids.
- * Passing a string will prefix that string to the header id.
- * Setting to true will add a generic 'section' prefix.
- *
- * @default false
- * @since 1.0.0
- */
- prefixHeaderId?: string | boolean;
- /**
- * Setting this option to true will prevent showdown from modifying the prefix.
- * This might result in malformed IDs (if, for instance, the " char is used in the prefix).
- * Has no effect if prefixHeaderId is set to false.
- *
- * @default false
- * @since 1.7.3
- */
- rawPrefixHeaderId?: boolean;
- /**
- * Remove only spaces, ' and " from generated header ids (including prefixes),
- * replacing them with dashes (-).
- * WARNING: This might result in malformed ids.
- *
- * @default false
- * @since 1.7.3
- */
- rawHeaderId?: boolean;
- /**
- * Enable support for setting image dimensions from within markdown syntax.
- *
- * @example
- * ```md
- *  simple, assumes units are in px
- *  sets the height to "auto"
- *  Image with width of 80% and height of 5em
- * ```
- * @default false
- * @since 1.1.0
- */
- parseImgDimensions?: boolean;
- /**
- * Set the header starting level. For instance, setting this to 3 means that
- *
- * @example
- * **input**:
- *
- * ```md
- * # header
- * ```
- *
- * **headerLevelStart** = 1
- *
- * ```html
- * <h1>header</h1>
- * ```
- *
- * **headerLevelStart** = 3
- *
- * ```html
- * <h3>header</h3>
- * ```
- * @default 1
- * @since 1.1.0
- */
- headerLevelStart?: number;
- /**
- * Turning this option on will enable automatic linking to urls.
- *
- * @example
- * **input**:
- *
- * ```md
- * some text www.google.com
- * ```
- *
- * **simplifiedAutoLink** = false
- *
- * ```html
- * <p>some text www.google.com</p>
- * ```
- *
- * **simplifiedAutoLink** = true
- *
- * ```html
- * <p>some text <a href="www.google.com">www.google.com</a></p>
- * ```
- * @default false
- * @since 1.2.0
- */
- simplifiedAutoLink?: boolean;
- /**
- * @deprecated https://github.com/showdownjs/showdown/commit/d3ebff7ef0cde5abfc3874463946d5297fc82e78
- *
- * This option excludes trailing punctuation from autolinking urls.
- * Punctuation excluded: . ! ? ( ).
- *
- * @remarks This option only applies to links generated by {@link Showdown.ShowdownOptions.simplifiedAutoLink}.
- * @example
- * **input**:
- *
- * ```md
- * check this link www.google.com.
- * ```
- *
- * **excludeTrailingPunctuationFromURLs** = false
- *
- * ```html
- * <p>check this link <a href="www.google.com">www.google.com.</a></p>
- * ```
- *
- * **excludeTrailingPunctuationFromURLs** = true
- *
- * ```html
- * <p>check this link <a href="www.google.com">www.google.com</a>.</p>
- * ```
- * @default false
- * @since 1.5.1
- */
- excludeTrailingPunctuationFromURLs?: boolean;
- /**
- * Turning this on will stop showdown from interpreting underscores in the middle of
- * words as <em> and <strong> and instead treat them as literal underscores.
- *
- * @example
- * **input**:
- *
- * ```md
- * some text with__underscores__in middle
- * ```
- *
- * **literalMidWordUnderscores** = false
- *
- * ```html
- * <p>some text with<strong>underscores</strong>in middle</p>
- * ```
- *
- * **literalMidWordUnderscores** = true
- *
- * ```html
- * <p>some text with__underscores__in middle</p>
- * ```
- * @default false
- * @since 1.2.0
- */
- literalMidWordUnderscores?: boolean;
- /**
- * Enable support for strikethrough syntax.
- *
- * @example
- * **syntax**:
- *
- * ```md
- * ~~strikethrough~~
- * ```
- *
- * ```html
- * <del>strikethrough</del>
- * ```
- * @default false
- * @since 1.2.0
- */
- strikethrough?: boolean;
- /**
- * Enable support for tables syntax.
- *
- * @example
- * **syntax**:
- *
- * ```md
- * | h1 | h2 | h3 |
- * |:------|:-------:|--------:|
- * | 100 | [a][1] | ![b][2] |
- * | *foo* | **bar** | ~~baz~~ |
- * ```
- * @default false
- * @since 1.2.0
- */
- tables?: boolean;
- /**
- * If enabled adds an id property to table headers tags.
- *
- * @remarks This options only applies if **[tables][]** is enabled.
- * @default false
- * @since 1.2.0
- */
- tablesHeaderId?: boolean;
- /**
- * Enable support for GFM code block style syntax (fenced codeblocks).
- *
- * @example
- * **syntax**:
- *
- * ```md
- * some code here
- * ```
- * @default true
- * @since 1.2.0
- */
- ghCodeBlocks?: boolean;
- /**
- * Enable support for GFM takslists.
- *
- * @example
- * **syntax**:
- *
- * ```md
- * - [x] This task is done
- * - [ ] This is still pending
- * ```
- * @default false
- * @since 1.2.0
- */
- tasklists?: boolean;
- /**
- * Prevents weird effects in live previews due to incomplete input.
- *
- * @example
- * 
- * You can prevent this by enabling this option.
- * @default false
- */
- smoothLivePreview?: boolean;
- /**
- * Tries to smartly fix indentation problems related to es6 template
- * strings in the midst of indented code.
- *
- * @default false
- * @since 1.4.2
- */
- smartIndentationFix?: boolean;
- /**
- * Disables the requirement of indenting sublists by 4 spaces for them to be nested,
- * effectively reverting to the old behavior where 2 or 3 spaces were enough.
- *
- * @example
- * **input**:
- *
- * ```md
- * - one
- * - two
- *
- * ...
- *
- * - one
- * - two
- * ```
- *
- * **disableForced4SpacesIndentedSublists** = false
- *
- * ```html
- * <ul>
- * <li>one</li>
- * <li>two</li>
- * </ul>
- * <p>...</p>
- * <ul>
- * <li>one
- * <ul>
- * <li>two</li>
- * </ul>
- * </li>
- * </ul>
- * ```
- *
- * **disableForced4SpacesIndentedSublists** = true
- *
- * ```html
- * <ul>
- * <li>one
- * <ul>
- * <li>two</li>
- * </ul>
- * </li>
- * </ul>
- * <p>...</p>
- * <ul>
- * <li>one
- * <ul>
- * <li>two</li>
- * </ul>
- * </li>
- * </ul>
- * ```
- * @default false
- * @since 1.5.0
- */
- disableForced4SpacesIndentedSublists?: boolean;
- /**
- * Parses line breaks as like GitHub does, without needing 2 spaces at the end of the line.
- *
- * @example
- * **input**:
- *
- * ```md
- * a line
- * wrapped in two
- * ```
- *
- * **simpleLineBreaks** = false
- *
- * ```html
- * <p>a line
- * wrapped in two</p>
- * ```
- *
- * **simpleLineBreaks** = true
- *
- * ```html
- * <p>a line<br>
- * wrapped in two</p>
- * ```
- * @default false
- * @since 1.5.1
- */
- simpleLineBreaks?: boolean;
- /**
- * Makes adding a space between # and the header text mandatory.
- *
- * @example
- * **input**:
- *
- * ```md
- * #header
- * ```
- *
- * **requireSpaceBeforeHeadingText** = false
- *
- * ```html
- * <h1 id="header">header</h1>
- * ```
- *
- * **simpleLineBreaks** = true
- *
- * ```html
- * <p>#header</p>
- * ```
- *
- * @default false
- * @since 1.5.3
- */
- requireSpaceBeforeHeadingText?: boolean;
- /**
- * Enables support for github @mentions, which links to the github profile page of the username mentioned.
- *
- * @example
- * **input**:
- *
- * ```md
- * hello there @tivie
- * ```
- *
- * **ghMentions** = false
- *
- * ```html
- * <p>hello there @tivie</p>
- * ```
- *
- * **ghMentions** = true
- *
- * ```html
- * <p>hello there <a href="https://www.github.com/tivie>@tivie</a></p>
- * ```
- * @default false
- * @since 1.6.0
- */
- ghMentions?: boolean;
- /**
- * Changes the link generated by @mentions. `{u}` is replaced by the text of the mentions. Only applies if **[ghMentions][]** is enabled.
- *
- * @example
- * **input**:
- *
- * ```md
- * hello there @tivie
- * ```
- *
- * **ghMentionsLink** = https://github.com/{u}
- *
- * ```html
- * <p>hello there <a href="https://www.github.com/tivie>@tivie</a></p>
- * ```
- *
- * **ghMentionsLink** = http://mysite.com/{u}/profile
- *
- * ```html
- * <p>hello there <a href="//mysite.com/tivie/profile">@tivie</a></p>
- * ```
- * @default https://github.com/{u}
- * @since 1.6.2
- */
- ghMentionsLink?: string;
- /**
- * Enables e-mail addresses encoding through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities.
- *
- * @remarks Prior to version 1.6.1, emails would always be obfuscated through dec and hex encoding.
- * @example
- * **input**:
- *
- * ```
- * <[email protected]>
- * ```
- *
- * **encodeEmails** = false
- *
- * ```html
- * <a href="mailto:[email protected]">[email protected]</a>
- * ```
- *
- * **encodeEmails** = true
- *
- * ```html
- * <a href="mailto:myself@example.com">myself@example.com</a>
- * ```
- * @default true
- * @since 1.6.1
- */
- encodeEmails?: boolean;
- /**
- * Open all links in new windows (by adding the attribute target="_blank" to <a> tags).
- *
- * @example
- * **input**:
- *
- * ```md
- * [Showdown](http://showdownjs.com)
- * ```
- *
- * **openLinksInNewWindow** = false
- * ```html
- * <p><a href="http://showdownjs.com">Showdown</a></p>
- * ```
- *
- * **openLinksInNewWindow** = true
- * ```html
- * <p><a href="http://showdownjs.com" target="_blank">Showdown</a></p>
- * ```
- * @default false
- * @since 1.7.0
- */
- openLinksInNewWindow?: boolean;
- /**
- * Support for HTML Tag escaping.
- *
- * @example
- * **input**:
- *
- * ```md
- * \<div>foo\</div>.
- * ```
- *
- * **backslashEscapesHTMLTags** = false
- * ```html
- * <p>\<div>foo\</div></p>
- * ```
- *
- * **backslashEscapesHTMLTags** = true
- * ```html
- * <p><div>foo</div></p>
- * ```
- * @default false
- * @since 1.7.2
- */
- backslashEscapesHTMLTags?: boolean;
- /**
- * Enable emoji support.
- *
- * @example
- * ```md
- * this is a :smile: emoji
- * ```
- * @default false
- * @see https://github.com/showdownjs/showdown/wiki/Emojis
- * @since 1.8.0
- */
- emoji?: boolean;
- /**
- * Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled,
- * underscores no longer parses into `<em>` and `<strong>`
- *
- * @example
- * **input**:
- *
- * ```md
- * __underline word__
- * ```
- *
- * **underline** = false
- * ```html
- * <p><strong>underlined word</strong></p>
- * ```
- *
- * **underline** = true
- * ```html
- * <p><u>underlined word</u></p>
- * ```
- * @default false
- * @since 1.8.0
- */
- underline?: boolean;
- /**
- * Outputs a complete html document, including <html>, <head> and <body> tags' instead of an HTML fragment.
- *
- * @example
- * **input**:
- *
- * ```md
- * # Showdown
- * ```
- *
- * **completeHTMLDocument** = false
- * ```html
- * <p><strong>Showdown</strong></p>
- * ```
- *
- * **completeHTMLDocument** = true
- * ```html
- * <!DOCTYPE HTML>
- * <html>
- * <head>
- * <meta charset="utf-8">
- * </head>
- * <body>
- * <p><strong>Showdown</strong></p>
- * </body>
- * </html>
- * ```
- * @default false
- * @since 1.8.5
- */
- completeHTMLDocument?: boolean;
- /**
- * Enable support for document metadata (defined at the top of the document
- * between `«««` and `»»»` or between `---` and `---`).
- *
- * @example
- * ```js
- * var conv = new showdown.Converter({metadata: true});
- * var html = conv.makeHtml(someMd);
- * var metadata = conv.getMetadata(); // returns an object with the document metadata
- * ```
- * @default false
- * @since 1.8.5
- */
- metadata?: boolean;
- /**
- * Split adjacent blockquote blocks.
- *
- * @since 1.8.6
- */
- splitAdjacentBlockquotes?: boolean;
- /**
- * For custom options {extension, subParser} And also an out-of-date definitions
- */
- [key:string]: any;
- }
- interface ConverterOptions extends ShowdownOptions {
- /**
- * Add extensions to the new converter can be showdown extensions or "global" extensions name.
- */
- extensions?: ((() => ShowdownExtension[] | ShowdownExtension) | ShowdownExtension[] | ShowdownExtension | string)[];
- }
- /**
- * Showdown Flavor names.
- */
- type Flavor = 'github' | 'original' | 'ghost' | 'vanilla' | 'allOn';
- /**
- * Showdown option description.
- */
- interface ShowdownOptionDescription {
- /**
- * The default value of option.
- */
- defaultValue?: boolean;
- /**
- * The description of the option.
- */
- description?: string;
- /**
- * The type of the option value.
- */
- type?: 'boolean' | 'string' | 'integer'
- }
- /**
- * Showdown options schema.
- */
- interface ShowdownOptionsSchema {
- [key: string]: ShowdownOptionDescription;
- }
- /**
- * Showdown subParser.
- */
- type SubParser = (...args: any[]) => string;
- /**
- * Showdown Converter prototype.
- *
- * @see https://github.com/showdownjs/showdown/blob/master/src/converter.js
- */
- interface Converter {
- /**
- * Listen to an event.
- *
- * @param name - The event name.
- * @param callback - The function that will be called when the event occurs.
- * @throws Throws if the type of `name` is not string.
- * @throws Throws if the type of `callback` is not function.
- * @example
- * ```ts
- * let converter: Converter = new Converter();
- * converter
- * .listen('hashBlock.before', (evtName, text, converter, options, globals) => {
- * // ... do stuff to text ...
- * return text;
- * })
- * .makeHtml('...');
- * ```
- */
- listen(name: string, callback: EventListener): Converter;
- /**
- * Converts a markdown string into HTML string.
- *
- * @param text - The input text (markdown).
- * @return The output HTML.
- */
- makeHtml(text: string): string;
- /**
- * Converts an HTML string into a markdown string.
- *
- * @param src - The input text (HTML)
- * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used.
- * @returns The output markdown.
- */
- makeMarkdown(src: string, HTMLParser?: HTMLDocument): string;
- /**
- * Setting a "local" option only affects the specified Converter object.
- *
- * @param key - The key of the option.
- * @param value - The value of the option.
- */
- setOption(key: string, value: any): void;
- /**
- * Get the option of this Converter instance.
- *
- * @param key - The key of the option.
- * @returns Returns the value of the given `key`.
- */
- getOption(key: string): any;
- /**
- * Get the options of this Converter instance.
- *
- * @returns Returns the current convertor options object.
- */
- getOptions(): ShowdownOptions;
- /**
- * Add extension to THIS converter.
- *
- * @param extension - The new extension to add.
- * @param name - The extension name.
- */
- addExtension(extension: (() => ShowdownExtension[] | ShowdownExtension) | ShowdownExtension[] | ShowdownExtension, name?: string): void;
- /**
- * Use a global registered extension with THIS converter.
- *
- * @param extensionName - Name of the previously registered extension.
- */
- useExtension(extensionName: string): void;
- /**
- * Set a "local" flavor for THIS Converter instance.
- *
- * @param flavor - The flavor name.
- */
- setFlavor(name: Flavor): void;
- /**
- * Get the "local" currently set flavor of this converter.
- *
- * @returns Returns string flavor name.
- */
- getFlavor(): Flavor;
- /**
- * Remove an extension from THIS converter.
- *
- * @remarks This is a costly operation. It's better to initialize a new converter.
- * and specify the extensions you wish to use.
- * @param extensions - The extensions to remove.
- */
- removeExtension(extensions: ShowdownExtension[] | ShowdownExtension): void;
- /**
- * Get all extensions.
- *
- * @return all extensions.
- */
- getAllExtensions(): ConverterExtensions;
- /**
- * Get the metadata of the previously parsed document.
- *
- * @param raw - If to returns Row or Metadata.
- * @returns Returns Row if `row` is `true`, otherwise Metadata.
- */
- getMetadata(raw?: boolean): string | Metadata
- /**
- * Get the metadata format of the previously parsed document.
- *
- * @returns Returns the metadata format.
- */
- getMetadataFormat(): string;
- }
- interface ConverterStatic {
- /**
- * @constructor
- * @param converterOptions - Configuration object, describes which extensions to apply.
- */
- new(converterOptions?: ConverterOptions): Converter;
- }
- /**
- * Helper Interface
- */
- interface Helper {
- replaceRecursiveRegExp(...args: any[]): string;
- [key: string]: (...args: any[]) => any;
- }
- /**
- * Constructor function for a Converter.
- */
- var Converter: ConverterStatic;
- /**
- * Showdown helper.
- */
- var helper: Helper;
- /**
- * Showdown extensions.
- */
- var extensions: ShowdownExtensions;
- /**
- * Setting a "global" option affects all instances of showdown.
- *
- * @param key - the option key.
- * @param value - the option value.
- */
- function setOption(key: string, value: any): typeof Showdown;
- /**
- * Get a "global" option.
- *
- * @param key - the option key.
- * @returns Returns the value of the given `key`.
- */
- function getOption(key: string): any;
- /**
- * Get the "global" options.
- *
- * @returns Returns a options object.
- */
- function getOptions(): ShowdownOptions;
- /**
- * Reset "global" options to the default values.
- */
- function resetOptions(): void;
- /**
- * Setting a "global" flavor affects all instances of showdown.
- *
- * @param name - The flavor name.
- */
- function setFlavor(name: Flavor): void;
- /**
- * Get the "global" currently set flavor.
- *
- * @returns Returns string flavor name.
- */
- function getFlavor(): Flavor;
- /**
- * Get the options of a specified flavor. Returns undefined if the flavor was not found.
- *
- * @param name - Name of the flavor.
- * @returns Returns options object of the given flavor `name`.
- */
- function getFlavorOptions(name: Flavor): ShowdownOptions | undefined;
- /**
- * Get the default options.
- *
- * @param [simple=true] - If to returns the default showdown options or the showdown options schema.
- * @returns Returns the options schema if `simple` is `false`, otherwise the default showdown options.
- */
- function getDefaultOptions(simple?: boolean): ShowdownOptionsSchema | ShowdownOptions;
- /**
- * Get a registered subParser.
- *
- * @param name - The parser name.
- * @returns Returns the parser of the given `name`.
- * @throws Throws if `name` is not of type string.
- * @throws Throws if the parser is not exists.
- */
- function subParser(name: string): SubParser;
- /**
- * Register a subParser.
- *
- * @param name - The name of the new parser.
- * @param func - The handler function of the new parser.
- * @throws Throws if `name` is not of type string.
- */
- function subParser(name: string, func: SubParser): void;
- /**
- * Get a registered extension.
- *
- * @param name - The extension name.
- * @returns Returns the extension of the given `name`.
- * @throws Throws if `name` is not of type string.
- * @throws Throws if the extension is not exists.
- */
- function extension(name: string): ShowdownExtension[];
- /**
- * Register a extension.
- *
- * @param name - The name of the new extension.
- * @param ext - The extension.
- * @throws Throws if `name` is not of type string.
- */
- function extension(name: string, ext: (() => ShowdownExtension[] | ShowdownExtension) | ShowdownExtension[] | ShowdownExtension): void;
- /**
- * Get the "global" extensions.
- *
- * @return Returns all extensions.
- */
- function getAllExtensions(): ShowdownExtensions;
- /**
- * Remove an extension.
- *
- * @param name - The extension name.
- */
- function removeExtension(name: string): void;
- /**
- * Removes all extensions.
- */
- function resetExtensions(): void;
- /**
- * Checks if the given `ext` is a valid showdown extension.
- *
- * @param ext - The extension to checks.
- * @returns Returns `true` if the extension is valid showdown extension, otherwise `false`.
- */
- function validateExtension(ext: ShowdownExtension[] | ShowdownExtension): boolean;
- }
|