Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add use method to extend markdown-it parser by plugin #105

Merged
merged 2 commits into from
Dec 2, 2018
Merged

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Dec 1, 2018

Added Marpit.use() instance method to extend markdown-it parser by plugin.

It is exactly same meaning as Marpit.markdown.use(), but it returns Marpit instance as chainable. It becomes easy to customize Marpit (Marp Core) especially in a functional engine implemented in Marp CLI (marp-team/marp-cli#42).

Usage in Marp Core / Marp CLI

// marp.config.js
const { Marp } = require('@marp-team/marp-core')
const container = require('markdown-it-container')
const mark = require('markdown-it-mark')

module.exports = {
  engine: opts => new Marp(opts).use(container, 'columns').use(mark),
}
<style>.columns { column-count: 2; }</style>

# Extend parser by ==markdown-it plugin==

::: columns
Lorem ipsum dolor sit amet, nec ex illud viderer vivendo, mea semper deleniti cu. His in brute justo. Vim facilisis dissentiet ei. Per cu efficiendi theophrastus, te pro dicta mucius, ut sed adhuc ponderum. No iriure convenire pri, ius at possit appareat disputando, mei ei libris oportere.
:::

deck

markdown-it-mark is using in the pre-released Marp but we are not planned to adopt in Marpit and Marp Core by not-standard syntax. markdown-it-container is also not adopted by the same reason.

However, this customization will help needed user. The example of multi column is one of the alternative way to r​esolve yhatt/marp#82.

ToDo

  • Add test

@yhatt yhatt merged commit 9a43283 into master Dec 2, 2018
@yhatt yhatt deleted the use-method branch December 2, 2018 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant