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

Custom directives support #125

Merged
merged 5 commits into from
Jan 28, 2019
Merged

Custom directives support #125

merged 5 commits into from
Jan 28, 2019

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Jan 28, 2019

Add Marpit.customDirectives property to define custom directives per instance. It resolves #124.

This object has the assignable global and local object. By defining the parser function to each object, Marpit would recognize additional directives. The parser should return the validated object that includes new value(s) for updating meta of markdown-it token.

The built-in directive parsers cannot overload by custom directives. The name of built-in directives cannot assign as new meta value too.

Currently, we do not intend to document about custom directives at https://marpit.marp.app/, because it will only affect internal tokens.

We will use that in the future VSCode plugin of Marp. Marp slide deck would be able to preview when marp: true is defined in front-matter. See yhatt/marp#118.

const marpit = new Marpit()
marpit.customDirectives.global.marp = v => ({ marp: v === 'true' })

@yhatt yhatt merged commit e626eca into master Jan 28, 2019
@yhatt yhatt deleted the custom-directives branch January 28, 2019 22:24
@yhatt
Copy link
Member Author

yhatt commented Jan 30, 2019

UPDATE: Directives must parse for recognizing marp: true, but a few plugins are still working when VSCode's markdown-it has extended by marpit.markdownItPlugins. To prevent breaking other VSCode plugins, we will change the approach to use the independent plugin for parsing marp: true. We enhanced markdown-it plugin system in #127.

The custom directive is still valuable for Marp Core.

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.

Custom directives
1 participant