A Rollup plugin to parse Markdown files.
- Markdown-it is used to parse the Markdown
- Front Matter is used to parse front-matter from the markdown file.
Plugins:
- Markdown-it-attrs
- Markdown-it-deflist
- Markdown-it-figure
- Markdown-it-highlightjs
- Markdown-it-kbd
- Markdown-it-mark
- Markdown-it-sub
- Markdown-it-sup
npm install --save-dev git:rbottomley/rollup-plugin-markdown
yarn add --dev git:rbottomley/rollup-plugin-markdown
import blogPost from './blog-post.md'
// from this import you get:
blogPost.html // the parsed HTML
blogPost.[frontmatter keys] // the front-matter
blogPost.slug // blog-post - the base of the filename that was imported
import markdown from 'rollup-plugin-markdown'
export default {
input: 'your-app.js',
plugins: [markdown()],
}
You can pass in two options: include
and exclude
, which are globs to limit which file(s) the plugin is applied to.
The plugin will only parse .md
files.
See the markdown-it and each plugin documentation for complete information. The "typography" option supports these replacements:
- Two hypens becomes an en dash: "--" to "–"
- Three hyphens becomes an em dash: "---" to "—"
- Single and double quotes converted to curly quotes
- "(c)" to "©"
- "(r)" to "®"
- "(p)" to "§"
- "(tm)" to "™"
- "..." and ".." to "…"
- "+-" to "±"
The "breaks" option honors line breaks.
Add classes, IDs and attributes to your markdown with {.class #id attr=value attr2="spaced value"} curly brackets, similar to pandoc's header attributes.
Create a definition list from:
Term
: definiton
Create figures with:
#1234[Caption](/url/to/image.png [Alt Text])
Use highlight.js to highlight code blocks.
Create kbd
element from double square brackets, such as:
[[dir c:]]
Keycaps are rendered via nested kbd
elements (per the spec):
[[[[Shift]]+[[F3]]]]
Create mark
element from double equals:
==highlighted text==
Create sub
element from tildes:
H2O
Create sup
element from circumflexes:
29^th^
- add markdown-it-deflist.
- update dependencies.
- update dependencies.
- add markdown-it-figure.
- add markdown-it-highlightjs.
- remove markdown-it-small, conflicts with en dash typography option.
- change filename key to slug and only return the basename sans extension.
- add more markdown-it plugins
- change markdown processor to markdown-it
- change front matter processor to front-matter
- add markdown-it-attrs plugin
- expose full path to Markdown file as
.path
from the import.
- Initial release