Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • markdownit

Index

Properties

Readonly block

block: ParserBlock

Instance of [[ParserBlock]]. You may need it to add new rules when writing plugins. For simple rules control use [[MarkdownIt.disable]] and [[MarkdownIt.enable]].

Readonly core

core: Core

Instance of [[Core]] chain executor. You may need it to add new rules when writing plugins. For simple rules control use [[MarkdownIt.disable]] and [[MarkdownIt.enable]].

Readonly helpers

helpers: Helpers

Readonly inline

inline: ParserInline

Instance of [[ParserInline]]. You may need it to add new rules when writing plugins. For simple rules control use [[MarkdownIt.disable]] and [[MarkdownIt.enable]].

Readonly linkify

linkify: LinkifyIt

linkify-it instance. Used by linkify rule.

Readonly options

Readonly renderer

renderer: Renderer

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

Example
var md = require('markdown-it')();

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

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

See Renderer docs and source code.

Readonly utils

utils: Utils

Methods

configure

  • 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

    Returns markdownit

disable

  • disable(list: string | string[], ignoreInvalid?: boolean): markdownit
  • chainable

    The same as [[MarkdownIt.enable]], but turn specified rules off.

    Parameters

    • list: string | string[]

      rule name or list of rule names to disable.

    • Optional ignoreInvalid: boolean

      set true to ignore errors when rule not found.

    Returns markdownit

enable

  • enable(list: string | string[], ignoreInvalid?: boolean): markdownit
  • 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
    var md = require('markdown-it')()
    .enable(['sub', 'sup'])
    .disable('smartquotes');

    Parameters

    • list: string | string[]

      rule name or list of rule names to enable

    • Optional ignoreInvalid: boolean

      set true to ignore errors when rule not found.

    Returns markdownit

normalizeLink

  • normalizeLink(url: string): string
  • Function used to encode link url to a machine-readable format, which includes url-encoding, punycode, etc.

    Parameters

    • url: string

    Returns string

normalizeLinkText

  • normalizeLinkText(url: string): string
  • Function used to decode link url to a human-readable format`

    Parameters

    • url: string

    Returns string

parse

  • parse(src: string, env: any): Token[]
  • internal

    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: any

      environment sandbox

    Returns Token[]

parseInline

  • parseInline(src: string, env: any): Token[]
  • internal

    The same as [[MarkdownIt.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: any

      environment sandbox

    Returns Token[]

render

  • render(src: string, env?: any): string
  • 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 [[MarkdownIt.parse]].

    Parameters

    • src: string

      source string

    • Optional env: any

      environment sandbox

    Returns string

renderInline

  • renderInline(src: string, env?: any): string
  • Similar to [[MarkdownIt.render]] but for single paragraph content. Result will NOT be wrapped into <p> tags.

    Parameters

    • src: string

      source string

    • Optional env: any

      environment sandbox

    Returns string

set

  • 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
    var md = require('markdown-it')()
    .set({ html: true, breaks: true })
    .set({ typographer: true });

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

    Parameters

    Returns markdownit

use

  • chainable

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

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

    Parameters

    Returns markdownit

  • Type parameters

    • T = any

    Parameters

    Returns markdownit

  • Parameters

    Returns markdownit

validateLink

  • validateLink(url: string): boolean
  • 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:

    var md = require('markdown-it')();
    // enable everything
    md.validateLink = function () { return true; }

    Parameters

    • url: string

    Returns boolean

Generated using TypeDoc