Marpit
Source: marpit.js:44
Parse Marpit Markdown and render to the slide HTML/CSS.
Constructor
new Marpit(opts?: Object): MarpitCreate a Marpit instance.
Parameters
opts(Object, optional)opts.anchor(boolean | Marpit~AnchorCallback, optional, default: true) — Set the page number as anchor of each slides (idattribute). You can customize the anchor text by defining a custom callback function.opts.container(false | Element | Array.<Element>, optional, default: "module:element.marpitContainer") — Container element(s) wrapping whole slide deck.opts.cssContainerQuery(boolean | string | Array.<string>, optional, default: false) — Set whether to enable CSS container query (@container). By setting the string or string array, you can specify the container name(s) for the CSS container.opts.cssNesting(boolean, optional, default: false) — Enable CSS nesting support. If enabled, Marpit will try to make flatten the CSS with nested rules before rendering, to make it compatible with Marpit preprocessings.opts.headingDivider(false | number | Array.<number>, optional, default: 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.opts.lang(string, optional) — Set the defaultlangattribute of each slide. It can override bylangglobal directive in the Markdown.opts.looseYAML(boolean, optional, default: false) — Allow loose YAML parsing in built-in directives, and custom directives defined in current instance.opts.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.opts.printable(boolean, optional, default: true) — Make style printable to PDF.opts.slideContainer(false | Element | Array.<Element>, optional) — Container element(s) wrapping each slide sections.opts.inlineSVG(boolean | Marpit~InlineSVGOptions, optional, default: false) — Wrap each slide sections by inline SVG. (Experimental)
Instance Methods
render(markdown: string, env?: Object): Marpit~RenderResult
Render Markdown into HTML and CSS string.
Parameters
markdown(string) — A Markdown string.env(Object, optional, default: "{}") — Environment object for passing to markdown-it.env.htmlAsArray(boolean, optional, default: false) — Output rendered HTML as array per slide.
Returns
Marpit~RenderResult— An object of rendering result.
use(plugin: function, ...params: *): Marpit
Load plugin either markdown-it or PostCSS into the current Marpit instance.
Parameters
plugin(function) — A markdown-it plugin or PostCSS plugin.params(*) — Params to pass into markdown-it plugin. (Not used in PostCSS plugin)
Returns
Instance Fields
options: Object
readonly
marpit.js:108The current options for this instance.
This property is read-only and marked as immutable. You cannot change the value of options after creating instance.
customDirectives: Object
readonly
marpit.js:125Definitions 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.
themeSet: ThemeSet
markdown: MarkdownIt
Other
InlineSVGOptions: Object
Properties
enabled(boolean, optional, default: true) — Whether inline SVG mode is enabled.backdropSelector(boolean, optional, default: true) — Whether::backdropselector support is enabled. If enabled, the::backdropCSS selector will match to the SVG container element.
AnchorCallback: function
Convert slide page index into anchor string.
Parameters
index(number) — Slide page index, beginning from zero.
Returns
string— The text of anchor for id attribute, without prefix#.
RenderResult: Object
Properties
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.