Skip to content

Class: MarkdownExit ​

Defined in: core.ts:50

Extends ​

Constructors ​

Constructor ​

ts
new MarkdownExit(options?): MarkdownExit;

Defined in: core.ts:81

Parameters ​

options? ​

MarkdownExitOptions

Returns ​

MarkdownExit

Overrides ​

Parser.constructor

Constructor ​

ts
new MarkdownExit(presetName, options?): MarkdownExit;

Defined in: core.ts:82

Parameters ​

presetName ​

PresetName

options? ​

MarkdownExitOptions

Returns ​

MarkdownExit

Overrides ​

ts
Parser.constructor

Properties ​

block ​

ts
block: ParserBlock<MarkdownExit>;

Defined in: parser/parser.ts:78

Instance of ParserBlock. You may need it to add new rules when writing plugins.

Inherited from ​

Parser.block


core ​

ts
core: Core<MarkdownExit>;

Defined in: parser/parser.ts:83

Instance of Core chain executor. You may need it to add new rules when writing plugins.

Inherited from ​

Parser.core


helpers ​

ts
helpers: object;

Defined in: parser/parser.ts:127

Link components parser functions, useful to write plugins. See details here.

parseLinkDestination() ​

ts
parseLinkDestination: (str, start, max) => ParseLinkDestinationResult;
Parameters ​
str ​

string

start ​

number

max ​

number

Returns ​

ParseLinkDestinationResult

parseLinkLabel() ​

ts
parseLinkLabel: (state, start, disableNested) => number;
Parameters ​
state ​

StateInline

start ​

number

disableNested ​

boolean = false

Returns ​

number

parseLinkTitle() ​

ts
parseLinkTitle: (str, start, max, prev_state?) => ParseLinkTitleResult;
Parameters ​
str ​

string

start ​

number

max ​

number

prev_state? ​

ParseLinkTitleResult

Returns ​

ParseLinkTitleResult

Inherited from ​

Parser.helpers


inline ​

ts
inline: ParserInline<MarkdownExit>;

Defined in: parser/parser.ts:73

Instance of ParserInline. You may need it to add new rules when writing plugins.

Inherited from ​

Parser.inline


linkify ​

ts
linkify: LinkifyIt;

Defined in: parser/parser.ts:90

linkify-it instance. Used by linkify rule. Unset in markdown-exit/core until you assign one.

Inherited from ​

Parser.linkify


options ​

ts
options: Required<MarkdownExitOptions>;

Defined in: core.ts:78

Overrides ​

Parser.options


renderer ​

ts
renderer: Renderer;

Defined in: core.ts:68

Instance of Renderer. Use it to modify output look. Or to add rendering rules for new token types, generated by plugins.

Example ​
javascript
function myToken(tokens, idx, options, env, self) {
  //...
  return result;
};

md.renderer.rules['my_token'] = myToken

See Renderer docs and source code.


utils ​

ts
utils: __module;

Defined in: core.ts:76

Assorted utility functions, useful to write plugins. See details here.


ParserBlock ​

ts
static ParserBlock: typeof default;

Defined in: core.ts:296


ParserCore ​

ts
static ParserCore: typeof default;

Defined in: core.ts:294


ParserInline ​

ts
static ParserInline: typeof default;

Defined in: core.ts:298


Renderer ​

ts
static Renderer: typeof Renderer;

Defined in: core.ts:293


Ruler ​

ts
static Ruler: typeof Ruler;

Defined in: core.ts:292


StateBlock ​

ts
static StateBlock: typeof StateBlock;

Defined in: core.ts:297


StateCore ​

ts
static StateCore: typeof StateCore;

Defined in: core.ts:295


StateInline ​

ts
static StateInline: typeof StateInline;

Defined in: core.ts:299


Token ​

ts
static Token: typeof Token;

Defined in: core.ts:291

Methods ​

configure() ​

ts
configure(presets): this;

Defined in: core.ts:130

chainable*, internal

Batch load of all options and compenent settings. This is internal method, and you probably will not need it. But if you with - see available presets and data structure here

We strongly recommend to use presets instead of direct config loads. That will give better compatibility with next versions.

Parameters ​

presets ​

PresetName | Preset

Returns ​

this


disable() ​

ts
disable(list, ignoreInvalid?): this;

Defined in: core.ts:205

chainable*

The same as MarkdownExit.enable, but turn specified rules off.

Parameters ​

list ​

rule name or list of rule names to disable.

string | string[]

ignoreInvalid? ​

boolean

set true to ignore errors when rule not found.

Returns ​

this


enable() ​

ts
enable(list, ignoreInvalid?): this;

Defined in: core.ts:175

chainable*

Enable list or rules. It will automatically find appropriate components, containing rules with given names. If rule not found, and ignoreInvalid not set - throws exception.

Example ​
javascript
md.enable(['sub', 'sup'])
  .disable('smartquotes');

Parameters ​

list ​

rule name or list of rule names to enable

string | string[]

ignoreInvalid? ​

boolean

set true to ignore errors when rule not found.

Returns ​

this


ts
normalizeLink(url): string;

Defined in: parser/parser.ts:112

Function used to encode link url to a machine-readable format, which includes url-encoding, punycode, etc.

Parameters ​

url ​

string

Returns ​

string

Inherited from ​

Parser.normalizeLink


normalizeLinkText() ​

ts
normalizeLinkText(url): string;

Defined in: parser/parser.ts:119

Function used to decode link url to a human-readable format`

Parameters ​

url ​

string

Returns ​

string

Inherited from ​

Parser.normalizeLinkText


parse() ​

ts
parse(src, env): Token[];

Defined in: parser/parser.ts:145

Parse input string and returns list of block tokens (special token type "inline" will contain list of inline tokens). You should not call this method directly, until you write custom renderer (for example, to produce AST).

env is used to pass data between "distributed" rules and return additional metadata like reference info, needed for the renderer. It also can be used to inject data in specific cases. Usually, you will be ok to pass {}, and then pass updated object to renderer.

Parameters ​

src ​

string

source string

env ​

MarkdownExitEnv = {}

environment sandbox

Returns ​

Token[]

Inherited from ​

Parser.parse


parseInline() ​

ts
parseInline(src, env): Token[];

Defined in: parser/parser.ts:162

The same as parse but skip all block rules. It returns the block tokens list with the single inline element, containing parsed inline tokens in children property. Also updates env object.

Parameters ​

src ​

string

source string

env ​

MarkdownExitEnv = {}

environment sandbox

Returns ​

Token[]

Inherited from ​

Parser.parseInline


render() ​

ts
render(src, env): string;

Defined in: core.ts:259

Render markdown string into html. It does all magic for you 😃.

env can be used to inject additional metadata ({} by default). But you will not need it with high probability. See also comment in MarkdownExit.parse.

Parameters ​

src ​

string

source string

env ​

MarkdownExitEnv = {}

environment sandbox

Returns ​

string


renderAsync() ​

ts
renderAsync(src, env): Promise<string>;

Defined in: core.ts:267

Async version of MarkdownExit.render. Runs all render rules in parallel (Promise.all) and preserves output order.

Parameters ​

src ​

string

env ​

MarkdownExitEnv = {}

Returns ​

Promise<string>


renderInline() ​

ts
renderInline(src, env): string;

Defined in: core.ts:278

Similar to MarkdownExit.render but for single paragraph content. Result will NOT be wrapped into <p> tags.

Parameters ​

src ​

string

source string

env ​

MarkdownExitEnv = {}

environment sandbox

Returns ​

string


renderInlineAsync() ​

ts
renderInlineAsync(src, env): Promise<string>;

Defined in: core.ts:286

Async version of MarkdownExit.renderInline. Runs all render rules in parallel (Promise.all) and preserves output order.

Parameters ​

src ​

string

env ​

MarkdownExitEnv = {}

Returns ​

Promise<string>


set() ​

ts
set(options): this;

Defined in: core.ts:115

chainable*

Set parser options (in the same format as in constructor). Probably, you will never need it, but you can change options after constructor call.

Example ​
javascript
md.set({ html: true, breaks: true })
  .set({ typographer: true });

Note: To achieve the best possible performance, don't modify a markdown-exit instance options on the fly. If you need multiple configurations it's best to create multiple instances and initialize each with separate config.

Parameters ​

options ​

MarkdownExitOptions

Returns ​

this


use() ​

Call Signature ​

ts
use(plugin): this;

Defined in: core.ts:241

chainable*

Load specified plugin with given params into current parser instance. It's just a sugar to call plugin(md, params) with curring.

Example ​
javascript
var iterator = require('markdown-it-for-inline');
md.use(iterator, 'foo_replace', 'text', function (tokens, idx) {
  tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
});
Parameters ​
plugin ​

PluginSimple

Returns ​

this

Call Signature ​

ts
use<T>(plugin, options?): this;

Defined in: core.ts:242

chainable*

Load specified plugin with given params into current parser instance. It's just a sugar to call plugin(md, params) with curring.

Example ​
javascript
var iterator = require('markdown-it-for-inline');
md.use(iterator, 'foo_replace', 'text', function (tokens, idx) {
  tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
});
Type Parameters ​
T ​

T = any

Parameters ​
plugin ​

PluginWithOptions<T>

options? ​

T

Returns ​

this

Call Signature ​

ts
use(plugin, ...params): this;

Defined in: core.ts:243

chainable*

Load specified plugin with given params into current parser instance. It's just a sugar to call plugin(md, params) with curring.

Example ​
javascript
var iterator = require('markdown-it-for-inline');
md.use(iterator, 'foo_replace', 'text', function (tokens, idx) {
  tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
});
Parameters ​
plugin ​

PluginWithParams

params ​

...any[]

Returns ​

this


ts
validateLink(url): boolean;

Defined in: parser/parser.ts:104

Link validation function. CommonMark allows too much in links. By default we disable javascript:, vbscript:, file: schemas, and almost all data:... schemas except some embedded image types.

You can change this behaviour:

javascript
// enable everything
md.validateLink = () => true

Parameters ​

url ​

string

Returns ​

boolean

Inherited from ​

Parser.validateLink

Released under the MIT License.