Home - uhop/grunt-slice-markdown GitHub Wiki
For old 0.1.x options see old docs.
Regular expression to split a markdown file on individual segments. By default it splits by horizontal rules as defined in the official documentation: horizontal rules.
Default: /^(?:\-(?:\s*\-){2,})|(?:_(?:\s*_){2,})|(?:\*(?:\s*\*){2,})\s*$/gm
Regular expression to detect and extract optional HTML attributes from a segment for its container. By default it is a line starting with :: — everything after that in line is considered a verbatim string of attributes. If omitted, an empty string is used.
Default: /^(?:\r?\n)*::\s+(.*?)\s*\r?\n/
Path to a template file, which is interpreted as JST popularized by underscore.template and lodash.template. Internally the plugin uses Lo-Dash's implementation.
Default: resources/template.jst, which is defined as
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><%= params.title || "Created with grunt-slice-markdown" %></title>
</head>
<body>
<article>
<% sections.forEach(function(section){ %>
<section <%= section.attributes %>><%= section.content %></section>
<% }); %>
</article>
</body>
</html>It is assumed that individual projects will use the default only for testing purposes, and will always supply their own template file to generate whatever text they need. You can find simple examples of different templates in tests/.
Object, which defines options passed to lodash.template, when it instantiates a template. See lodash.template documentation for more details.
As an example, it is possible to redefine delimiters to use something truly custom.
Default: {}.
Object, which is passed to a template as params. Can be anything.
Default: {}.
Object, which governs behavior of a Markdown processor. Internally the plugin uses markdown-it. See its documentation for more details.
For convenience, a number of useful plugins is included, as well as a custom tag to wrap an arbitrary text in a container with user-specified CSS classes. Read all about it in how markdown-it is used.
Default: {html: true, typographer: true}.
When instantiating a template with a segment, two parameters are passed down with following names:
-
sectionsis an array of objects describing individual sections. Each object has two properties:-
attributesis a string of optional attributes extracted by plugin (see above the corresponding option). It is an empty string, when unspecified. -
contentis a string, which holds a literal text of a segment.
-
-
paramsis a custom object passed to the plugin as an option (see above).