Skip to content

rbottomley/rollup-plugin-markdown

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rollup-plugin-markdown

rbottomley

A Rollup plugin to parse Markdown files.

Plugins:

Install

npm install --save-dev git:rbottomley/rollup-plugin-markdown

yarn add --dev git:rbottomley/rollup-plugin-markdown

Example module output

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

Rollup configuration

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.

Markdown options

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.

"markdown-it-attrs" plugin

Add classes, IDs and attributes to your markdown with {.class #id attr=value attr2="spaced value"} curly brackets, similar to pandoc's header attributes.

"markdown-it-deflist" plugin

Create a definition list from:

Term

: definiton

"markdown-it-figure" plugin

Create figures with:

#1234[Caption](/url/to/image.png [Alt Text])

"markdown-it-highlightjs" plugin

Use highlight.js to highlight code blocks.

"markdown-it-kbd" plugin

Create kbd element from double square brackets, such as:

[[dir c:]]

Keycaps are rendered via nested kbd elements (per the spec):

[[[[Shift]]+[[F3]]]]

"markdown-it-mark" plugin

Create mark element from double equals:

==highlighted text==

"markdown-it-sub" plugin

Create sub element from tildes:

H2O

"markdown-it-sup" plugin

Create sup element from circumflexes:

29^th^

Changelog

2.4.0

  • add markdown-it-deflist.
  • update dependencies.

2.3.1

  • update dependencies.

2.3.0

  • add markdown-it-figure.

2.2.0

  • add markdown-it-highlightjs.

2.1.0

  • remove markdown-it-small, conflicts with en dash typography option.

2.0.0

  • change filename key to slug and only return the basename sans extension.

1.1.0

  • add more markdown-it plugins

1.0.0

  • change markdown processor to markdown-it
  • change front matter processor to front-matter
  • add markdown-it-attrs plugin

0.2.0

  • expose full path to Markdown file as .path from the import.

0.1.0

  • Initial release

About

A Rollup plugin to parse Markdown files using markdown-it.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • JavaScript 100.0%