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
backgroundSyntax boolean <optional>
true

Support markdown image syntax with the alternate text including bg. Normally it converts into spot directives about background image. If inlineSVG is enabled, it supports the advanced backgrounds.

container false | Element | Array.<Element> <optional>
module:element.marpitContainer

Container element(s) wrapping whole slide deck.

filters boolean <optional>
true

Support filter syntax for markdown image. It can apply to inline image and the advanced backgrounds.

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.

inlineStyle boolean <optional>
true

Recognize <style> elements to append additional styles to theme. When it is true, Marpit will parse style regardless markdown-it's html option.

looseYAML boolean <optional>
false

Allow loose YAML for directives.

markdown string | Object | Array <optional>
'commonmark'

markdown-it initialize option(s).

printable boolean <optional>
true

Make style printable to PDF.

scopedStyle boolean <optional>
true

Support scoping inline style to the current slide through <style scoped> when inlineStyle is enabled.

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

(static, 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

(static, 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

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.

Source:
Type:
  • function

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