@types/showdown
- Version 2.0.6
- Published
- 37.6 kB
- No dependencies
- MIT license
Install
npm i @types/showdown
yarn add @types/showdown
pnpm add @types/showdown
Overview
TypeScript definitions for showdown
Index
Variables
Functions
Interfaces
ShowdownOptions
- backslashEscapesHTMLTags
- completeHTMLDocument
- customizedHeaderId
- disableForced4SpacesIndentedSublists
- ellipsis
- emoji
- encodeEmails
- excludeTrailingPunctuationFromURLs
- ghCodeBlocks
- ghCompatibleHeaderId
- ghMentions
- ghMentionsLink
- headerLevelStart
- literalMidWordUnderscores
- metadata
- noHeaderId
- omitExtraWLInCodeBlocks
- openLinksInNewWindow
- parseImgDimensions
- prefixHeaderId
- rawHeaderId
- rawPrefixHeaderId
- requireSpaceBeforeHeadingText
- simpleLineBreaks
- simplifiedAutoLink
- smartIndentationFix
- smoothLivePreview
- splitAdjacentBlockquotes
- strikethrough
- tables
- tablesHeaderId
- tasklists
- underline
Type Aliases
Variables
variable Converter
var Converter: ConverterStatic;
Constructor function for a Converter.
variable extensions
var extensions: ShowdownExtensions;
Showdown extensions.
variable helper
var helper: Helper;
Showdown helper.
Functions
function extension
extension: { (name: string): ShowdownExtension[]; ( name: string, ext: | ShowdownExtension | ShowdownExtension[] | (() => ShowdownExtension | ShowdownExtension[]) ): void;};
Get a registered extension.
Parameter 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.
Register a extension.
Parameter name
The name of the new extension.
Parameter ext
The extension.
Throws
Throws if
name
is not of type string.
function getAllExtensions
getAllExtensions: () => ShowdownExtensions;
Get the "global" extensions.
Returns all extensions.
function getDefaultOptions
getDefaultOptions: (simple?: boolean) => ShowdownOptionsSchema | ShowdownOptions;
Get the default options.
Parameter simple
If to returns the default showdown options or the showdown options schema.
Returns
Returns the options schema if
simple
isfalse
, otherwise the default showdown options.
function getFlavor
getFlavor: () => Flavor;
Get the "global" currently set flavor.
Returns
Returns string flavor name.
function getFlavorOptions
getFlavorOptions: (name: Flavor) => ShowdownOptions | undefined;
Get the options of a specified flavor. Returns undefined if the flavor was not found.
Parameter name
Name of the flavor.
Returns
Returns options object of the given flavor
name
.
function getOption
getOption: (key: string) => any;
Get a "global" option.
Parameter key
the option key.
Returns
Returns the value of the given
key
.
function getOptions
getOptions: () => ShowdownOptions;
Get the "global" options.
Returns
Returns a options object.
function removeExtension
removeExtension: (name: string) => void;
Remove an extension.
Parameter name
The extension name.
function resetExtensions
resetExtensions: () => void;
Removes all extensions.
function resetOptions
resetOptions: () => void;
Reset "global" options to the default values.
function setFlavor
setFlavor: (name: Flavor) => void;
Setting a "global" flavor affects all instances of showdown.
Parameter name
The flavor name.
function setOption
setOption: (key: string, value: any) => typeof Showdown;
Setting a "global" option affects all instances of showdown.
Parameter key
the option key.
Parameter value
the option value.
function subParser
subParser: { (name: string): SubParser; (name: string, func: SubParser): void };
Get a registered subParser.
Parameter 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.
Register a subParser.
Parameter name
The name of the new parser.
Parameter func
The handler function of the new parser.
Throws
Throws if
name
is not of type string.
function validateExtension
validateExtension: (ext: ShowdownExtension[] | ShowdownExtension) => boolean;
Checks if the given
ext
is a valid showdown extension.Parameter ext
The extension to checks.
Returns
Returns
true
if the extension is valid showdown extension, otherwisefalse
.
Interfaces
interface Converter
interface Converter {}
Showdown Converter prototype.
See Also
https://github.com/showdownjs/showdown/blob/master/src/converter.js
method addExtension
addExtension: ( extension: | (() => ShowdownExtension[] | ShowdownExtension) | ShowdownExtension[] | ShowdownExtension, name?: string) => void;
Add extension to THIS converter.
Parameter extension
The new extension to add.
Parameter name
The extension name.
method getAllExtensions
getAllExtensions: () => ConverterExtensions;
Get all extensions.
all extensions.
method getFlavor
getFlavor: () => Flavor;
Get the "local" currently set flavor of this converter.
Returns
Returns string flavor name.
method getMetadata
getMetadata: (raw?: boolean) => string | Metadata;
Get the metadata of the previously parsed document.
Parameter raw
If to returns Row or Metadata.
Returns
Returns Row if
row
istrue
, otherwise Metadata.
method getMetadataFormat
getMetadataFormat: () => string;
Get the metadata format of the previously parsed document.
Returns
Returns the metadata format.
method getOption
getOption: (key: string) => any;
Get the option of this Converter instance.
Parameter key
The key of the option.
Returns
Returns the value of the given
key
.
method getOptions
getOptions: () => ShowdownOptions;
Get the options of this Converter instance.
Returns
Returns the current convertor options object.
method listen
listen: (name: string, callback: EventListener) => Converter;
Listen to an event.
Parameter name
The event name.
Parameter 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 1
let converter: Converter = new Converter();converter.listen('hashBlock.before', (evtName, text, converter, options, globals) => {// ... do stuff to text ...return text;}).makeHtml('...');
method makeHtml
makeHtml: (text: string) => string;
Converts a markdown string into HTML string.
Parameter text
The input text (markdown). The output HTML.
method makeMarkdown
makeMarkdown: (src: string, HTMLParser?: HTMLDocument) => string;
Converts an HTML string into a markdown string.
Parameter src
The input text (HTML)
Parameter HTMLParser
A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used.
Returns
The output markdown.
method removeExtension
removeExtension: (extensions: ShowdownExtension[] | ShowdownExtension) => void;
Remove an extension from THIS converter.
Parameter extensions
The extensions to remove.
Remarks
This is a costly operation. It's better to initialize a new converter. and specify the extensions you wish to use.
method setFlavor
setFlavor: (name: Flavor) => void;
Set a "local" flavor for THIS Converter instance.
Parameter flavor
The flavor name.
method setOption
setOption: (key: string, value: any) => void;
Setting a "local" option only affects the specified Converter object.
Parameter key
The key of the option.
Parameter value
The value of the option.
method useExtension
useExtension: (extensionName: string) => void;
Use a global registered extension with THIS converter.
Parameter extensionName
Name of the previously registered extension.
interface ConverterExtensions
interface ConverterExtensions {}
Showdown converter extensions store object.
interface ConverterGlobals
interface ConverterGlobals {}
property converter
converter?: Converter | undefined;
property gDimensions
gDimensions?: | { width?: number | undefined; height?: number | undefined; } | undefined;
property ghCodeBlocks
ghCodeBlocks?: | Array<{ codeblock?: string | undefined; text?: string | undefined }> | undefined;
property gHtmlBlocks
gHtmlBlocks?: string[] | undefined;
property gHtmlMdBlocks
gHtmlMdBlocks?: string[] | undefined;
property gHtmlSpans
gHtmlSpans?: string[] | undefined;
property gListLevel
gListLevel?: number | undefined;
property gTitles
gTitles?: { [key: string]: string } | undefined;
property gUrls
gUrls?: { [key: string]: string } | undefined;
property hashLinkCounts
hashLinkCounts?: { [key: string]: number } | undefined;
property langExtensions
langExtensions?: ShowdownExtension[] | undefined;
property metadata
metadata?: | { parsed?: { [key: string]: string } | undefined; raw?: string | undefined; format?: string | undefined; } | undefined;
property outputModifiers
outputModifiers?: ShowdownExtension[] | undefined;
interface ConverterOptions
interface ConverterOptions extends ShowdownOptions {}
property extensions
extensions?: | Array< | (() => ShowdownExtension[] | ShowdownExtension) | ShowdownExtension[] | ShowdownExtension | string > | undefined;
Add extensions to the new converter can be showdown extensions or "global" extensions name.
interface ConverterStatic
interface ConverterStatic {}
construct signature
new (converterOptions?: ConverterOptions): Converter;
Parameter converterOptions
Configuration object, describes which extensions to apply.
interface EventListener
interface EventListener {}
Showdown event listener.
call signature
( evtName: string, text: string, converter: Converter, options: ShowdownOptions, globals: ConverterGlobals // eslint-disable-next-line @typescript-eslint/no-invalid-void-type): void | string;
Parameter evtName
The event name.
Parameter text
The current convert value.
Parameter converter
The converter instance.
Parameter options
The converter options.
Parameter globals
A global parsed data of the current conversion.
Returns
Can be returned string value to change the current convert value (
text
).Example 1
Change by returns string value.
let listener: EventListener = (evtName, text, converter, options, globals) => doSome(text);
interface Extension
interface Extension {}
property listeners
listeners?: { [event: string]: EventListener } | undefined;
Event listeners functions that called on the conversion, when the
event
occurs.
property type
type: string;
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.
interface FilterExtension
interface FilterExtension extends Extension {}
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 1
let myExt: ShowdownExtension = {type: 'lang',filter: (text: string, converter: Converter) => text.replace('#', '*')};
property filter
filter?: | (( text: string, converter: Converter, options?: ConverterOptions ) => string) | undefined;
interface Helper
interface Helper {}
Helper Interface
method replaceRecursiveRegExp
replaceRecursiveRegExp: (...args: any[]) => string;
index signature
[key: string]: (...args: any[]) => any;
interface Metadata
interface Metadata {}
index signature
[meta: string]: string;
interface RegexReplaceExtension
interface RegexReplaceExtension extends Extension {}
Regex/replace style extensions are very similar to javascript's string.replace function. Two properties are given,
regex
andreplace
.Example 1
let myExt: RegexReplaceExtension = {type: 'lang',regex: /markdown/g,replace: 'showdown'};
property regex
regex?: string | RegExp | undefined;
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.
property replace
replace?: any;
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).
interface ShowdownExtension
interface ShowdownExtension extends RegexReplaceExtension, FilterExtension {}
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 to be , 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 1
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 ShowdownExtensions
interface ShowdownExtensions {}
Showdown extensions store object.
index signature
[name: string]: ShowdownExtension[];
interface ShowdownOptionDescription
interface ShowdownOptionDescription {}
Showdown option description.
property defaultValue
defaultValue?: boolean | undefined;
The default value of option.
property description
description?: string | undefined;
The description of the option.
property type
type?: 'boolean' | 'string' | 'integer' | undefined;
The type of the option value.
interface ShowdownOptions
interface ShowdownOptions {}
Showdown options.
See Also
https://github.com/showdownjs/showdown#valid-options
https://github.com/showdownjs/showdown/wiki/Showdown-options
https://github.com/showdownjs/showdown/blob/master/src/options.js
property backslashEscapesHTMLTags
backslashEscapesHTMLTags?: boolean | undefined;
Support for HTML Tag escaping.
Example 1
**input**:
\<div>foo\</div>.**backslashEscapesHTMLTags** = false
<p>\<div>foo\</div></p>**backslashEscapesHTMLTags** = true
<p><div>foo</div></p>false 1.7.2
property completeHTMLDocument
completeHTMLDocument?: boolean | undefined;
Outputs a complete html document, including , and tags' instead of an HTML fragment.
Example 1
**input**:
# Showdown**completeHTMLDocument** = false
<p><strong>Showdown</strong></p>**completeHTMLDocument** = true
<!DOCTYPE HTML><html><head><meta charset="utf-8"></head><body><p><strong>Showdown</strong></p></body></html>false 1.8.5
property customizedHeaderId
customizedHeaderId?: boolean | undefined;
Use text in curly braces as header id.
Example 1
```md ## Sample header {real-id} will use real-id as id ``` false 1.7.0
property disableForced4SpacesIndentedSublists
disableForced4SpacesIndentedSublists?: boolean | undefined;
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 1
**input**:
- one- two...- one- two**disableForced4SpacesIndentedSublists** = false
<ul><li>one</li><li>two</li></ul><p>...</p><ul><li>one<ul><li>two</li></ul></li></ul>**disableForced4SpacesIndentedSublists** = true
<ul><li>one<ul><li>two</li></ul></li></ul><p>...</p><ul><li>one<ul><li>two</li></ul></li></ul>false 1.5.0
property ellipsis
ellipsis?: boolean | undefined;
Replaces three dots with the ellipsis unicode character. true
property emoji
emoji?: boolean | undefined;
Enable emoji support.
Example 1
this is a :smile: emojifalse
See Also
https://github.com/showdownjs/showdown/wiki/Emojis 1.8.0
property encodeEmails
encodeEmails?: boolean | undefined;
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 1
**input**:
<myself@example.com>**encodeEmails** = false
<a href="mailto:myself@example.com">myself@example.com</a>**encodeEmails** = true
<a href="mailto:myself@example.com">myself@example.com</a>true 1.6.1
property excludeTrailingPunctuationFromURLs
excludeTrailingPunctuationFromURLs?: boolean | undefined;
Remarks
This option only applies to links generated by Showdown.ShowdownOptions.simplifiedAutoLink.
Example 1
**input**:
check this link www.google.com.**excludeTrailingPunctuationFromURLs** = false
<p>check this link <a href="www.google.com">www.google.com.</a></p>**excludeTrailingPunctuationFromURLs** = true
<p>check this link <a href="www.google.com">www.google.com</a>.</p>false 1.5.1
Deprecated
https://github.com/showdownjs/showdown/commit/d3ebff7ef0cde5abfc3874463946d5297fc82e78
This option excludes trailing punctuation from autolinking urls. Punctuation excluded: . ! ? ( ).
property ghCodeBlocks
ghCodeBlocks?: boolean | undefined;
Enable support for GFM code block style syntax (fenced codeblocks).
Example 1
**syntax**:
```md some code here ``` true 1.2.0
property ghCompatibleHeaderId
ghCompatibleHeaderId?: boolean | undefined;
Generate header ids compatible with github style (spaces are replaced with dashes and a bunch of non alphanumeric chars are removed).
Example 1
**input**:
# This is a header with @#$%**ghCompatibleHeaderId** = false
<h1 id="thisisaheader">This is a header</h1>**ghCompatibleHeaderId** = true
<h1 id="this-is-a-header-with-">This is a header with @#$%</h1>false 1.5.5
property ghMentions
ghMentions?: boolean | undefined;
Enables support for github @mentions, which links to the github profile page of the username mentioned.
Example 1
**input**:
hello there @tivie**ghMentions** = false
<p>hello there @tivie</p>**ghMentions** = true
<p>hello there <a href="https://www.github.com/tivie>@tivie</a></p>false 1.6.0
property ghMentionsLink
ghMentionsLink?: string | undefined;
Changes the link generated by @mentions.
{u}
is replaced by the text of the mentions. Only applies if **[ghMentions][]** is enabled.Example 1
**input**:
hello there @tivie**ghMentionsLink** = https://github.com/{u}
<p>hello there <a href="https://www.github.com/tivie>@tivie</a></p>**ghMentionsLink** = http://mysite.com/{u}/profile
<p>hello there <a href="//mysite.com/tivie/profile">@tivie</a></p>https://github.com/{u} 1.6.2
property headerLevelStart
headerLevelStart?: number | undefined;
Set the header starting level. For instance, setting this to 3 means that
Example 1
**input**:
# header**headerLevelStart** = 1
<h1>header</h1>**headerLevelStart** = 3
<h3>header</h3>1 1.1.0
property literalMidWordUnderscores
literalMidWordUnderscores?: boolean | undefined;
Turning this on will stop showdown from interpreting underscores in the middle of words as and and instead treat them as literal underscores.
Example 1
**input**:
some text with__underscores__in middle**literalMidWordUnderscores** = false
<p>some text with<strong>underscores</strong>in middle</p>**literalMidWordUnderscores** = true
<p>some text with__underscores__in middle</p>false 1.2.0
property metadata
metadata?: boolean | undefined;
Enable support for document metadata (defined at the top of the document between
«««
and»»»
or between---
and---
).Example 1
```js var conv = new showdown.Converter({metadata: true}); var html = conv.makeHtml(someMd); var metadata = conv.getMetadata(); // returns an object with the document metadata ``` false 1.8.5
property noHeaderId
noHeaderId?: boolean | undefined;
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 1
**input**:
# This is a header**noHeaderId** = false
<h1 id="thisisaheader">This is a header</h1>**noHeaderId** = true
<h1>This is a header</h1>false 1.1.0
property omitExtraWLInCodeBlocks
omitExtraWLInCodeBlocks?: boolean | undefined;
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 1
**input**:
var foo = 'bar';**omitExtraWLInCodeBlocks** = false:
<code><pre>var foo = 'bar';</pre></code>**omitExtraWLInCodeBlocks** = true:
<code><pre>var foo = 'bar';</pre></code>false 1.0.0
property openLinksInNewWindow
openLinksInNewWindow?: boolean | undefined;
Open all links in new windows (by adding the attribute target="_blank" to tags).
Example 1
**input**:
[Showdown](http://showdownjs.com)**openLinksInNewWindow** = false
<p><a href="http://showdownjs.com">Showdown</a></p>**openLinksInNewWindow** = true
<p><a href="http://showdownjs.com" target="_blank">Showdown</a></p>false 1.7.0
property parseImgDimensions
parseImgDimensions?: boolean | undefined;
Enable support for setting image dimensions from within markdown syntax.
Example 1
![foo](foo.jpg =100x80) simple, assumes units are in px![bar](bar.jpg =100x*) sets the height to "auto"![baz](baz.jpg =80%x5em) Image with width of 80% and height of 5emfalse 1.1.0
property prefixHeaderId
prefixHeaderId?: string | boolean | undefined;
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.
false 1.0.0
property rawHeaderId
rawHeaderId?: boolean | undefined;
Remove only spaces, ' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids.
false 1.7.3
property rawPrefixHeaderId
rawPrefixHeaderId?: boolean | undefined;
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.
false 1.7.3
property requireSpaceBeforeHeadingText
requireSpaceBeforeHeadingText?: boolean | undefined;
Makes adding a space between # and the header text mandatory.
Example 1
**input**:
#header**requireSpaceBeforeHeadingText** = false
<h1 id="header">header</h1>**simpleLineBreaks** = true
<p>#header</p>false 1.5.3
property simpleLineBreaks
simpleLineBreaks?: boolean | undefined;
Parses line breaks as like GitHub does, without needing 2 spaces at the end of the line.
Example 1
**input**:
a linewrapped in two**simpleLineBreaks** = false
<p>a linewrapped in two</p>**simpleLineBreaks** = true
<p>a line<br>wrapped in two</p>false 1.5.1
property simplifiedAutoLink
simplifiedAutoLink?: boolean | undefined;
Turning this option on will enable automatic linking to urls.
Example 1
**input**:
some text www.google.com**simplifiedAutoLink** = false
<p>some text www.google.com</p>**simplifiedAutoLink** = true
<p>some text <a href="www.google.com">www.google.com</a></p>false 1.2.0
property smartIndentationFix
smartIndentationFix?: boolean | undefined;
Tries to smartly fix indentation problems related to es6 template strings in the midst of indented code.
false 1.4.2
property smoothLivePreview
smoothLivePreview?: boolean | undefined;
Prevents weird effects in live previews due to incomplete input.
Example 1
![awkward effect](http://i.imgur.com/YQ9iHTL.gif) You can prevent this by enabling this option. false
property splitAdjacentBlockquotes
splitAdjacentBlockquotes?: boolean | undefined;
Split adjacent blockquote blocks.
1.8.6
property strikethrough
strikethrough?: boolean | undefined;
Enable support for strikethrough syntax.
Example 1
**syntax**:
~~strikethrough~~<del>strikethrough</del>false 1.2.0
property tables
tables?: boolean | undefined;
Enable support for tables syntax.
Example 1
**syntax**:
| h1 | h2 | h3 ||:------|:-------:|--------:|| 100 | [a][1] | ![b][2] || *foo* | **bar** | ~~baz~~ |false 1.2.0
property tablesHeaderId
tablesHeaderId?: boolean | undefined;
If enabled adds an id property to table headers tags.
Remarks
This options only applies if **[tables][]** is enabled. false 1.2.0
property tasklists
tasklists?: boolean | undefined;
Enable support for GFM takslists.
Example 1
**syntax**:
- [x] This task is done- [ ] This is still pendingfalse 1.2.0
property underline
underline?: boolean | undefined;
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 1
**input**:
__underline word__**underline** = false
<p><strong>underlined word</strong></p>**underline** = true
<p><u>underlined word</u></p>false 1.8.0
index signature
[key: string]: any;
For custom options {extension, subParser} And also an out-of-date definitions
interface ShowdownOptionsSchema
interface ShowdownOptionsSchema {}
Showdown options schema.
index signature
[key: string]: ShowdownOptionDescription;
Type Aliases
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/showdown
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/showdown)
- HTML<a href="https://www.jsdocs.io/package/@types/showdown"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4060 ms. - Missing or incorrect documentation? Open an issue for this package.