0.1.4 • Published 5 years ago

markdown-it-condition v0.1.4

Weekly downloads
122
License
MIT
Repository
github
Last release
5 years ago

markdown-it-condition

Plugin for creating if-else conditional blocks for markdown-it markdown parser.

With this plugin you can create conditional block like:

::if condition
*Show if condition is true*
::else
*Show if condition is false*
::endif

... and the selected content will be rendered as markdown markup.

<p><em>This text will be shown</em></p>

Derived from markdown-it-container.

Installation

node.js, browser:

$ npm install markdown-it-condition --save
$ bower install markdown-it-condition --save

API

var md = require('markdown-it')()
            .use(require('markdown-it-condition'), name [, options]);

Example

var md = require('markdown-it')();

md.use(require('markdown-it-condition'));

console.log(md.render('::if flag.value\n*This text will be shown*\n::else\n*This text won\'t\n::endif'), {
    flag: {
        value: true
    }
});

// Output:
//
// <p><em>This text will be shown</em></p>

License

MIT