Marpit

Marpit

Parse Marpit Markdown and render to the slide HTML/CSS.

Constructor

new Marpit(optsopt)

Create a Marpit instance.

Source:
Parameters:
Name Type Attributes Description
opts Object <optional>
Name Type Attributes Default Description
container false | Element | Array.<Element> <optional>
module:element.marpitContainer

Container element(s) wrapping whole slide deck.

headingDivider false | number | Array.<number> <optional>
false

Start a new slide page at before of headings. it would apply to headings whose larger than or equal to the specified level if a number is given, or ONLY specified levels if a number array.

looseYAML boolean <optional>
false

Allow loose YAML parsing in built-in directives, and custom directives defined in current instance.

markdown MarkdownIt | string | Object | Array <optional>

An instance of markdown-it or its constructor option(s) for wrapping. Marpit will create its instance based on CommonMark when omitted.

printable boolean <optional>
true

Make style printable to PDF.

slideContainer false | Element | Array.<Element> <optional>

Container element(s) wrapping each slide sections.

inlineSVG boolean <optional>
false

Wrap each sections by inline SVG. (Experimental)

Members

(readonly) customDirectives :Object

Definitions of the custom directive.

It has the assignable global and local object. They have consisted of the directive name as a key, and parser function as a value. The parser should return the validated object for updating meta of markdown-it token.

Source:
Type:
  • Object

markdown :MarkdownIt

Source:
Type:
  • MarkdownIt

(readonly) markdownItPlugins :function

The plugin interface of markdown-it for current Marpit instance.

This is useful to integrate Marpit with the other markdown-it based parser.

Deprecated:
  • A plugin interface for markdown-it is deprecated and will remove in future version. Instead, wrap markdown-it instance when creating Marpit by `new Marpit({ markdown: markdownItInstance })`.
Source:
Type:
  • function

(readonly) options :Object

The current options for this instance.

This property is read-only and marked as immutable. You cannot change the value of options after creating instance.

Source:
Type:
  • Object

themeSet :ThemeSet

Source:
Type:

Methods

render(markdown, envopt) → {Marpit~RenderResult}

Render Markdown into HTML and CSS string.

Source:
Parameters:
Name Type Attributes Default Description
markdown string

A Markdown string.

env Object <optional>
{}

Environment object for passing to markdown-it.

Name Type Attributes Default Description
htmlAsArray boolean <optional>
false

Output rendered HTML as array per slide.

Returns:
Type:
Marpit~RenderResult

An object of rendering result.

use(plugin, …params) → {Marpit}

Load the specified markdown-it plugin with given parameters.

Source:
Parameters:
Name Type Attributes Description
plugin function

markdown-it plugin.

params * <repeatable>

Params to pass into plugin.

Returns:
Type:
Marpit

The called Marpit instance for chainable.

Type Definitions

RenderResult

Properties:
Name Type Description
html string | Array.<string>

Rendered HTML.

css string

Rendered CSS.

comments Array.<Array.<string>>

Parsed HTML comments per slide pages, excepted YAML for directives. It would be useful for presenter notes.

Source:
Type:
  • Object