markdown-it-container

WebJar for markdown-it-container

License

License

MIT
Categories

Categories

Container
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

markdown-it-container
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

markdown-it-container
WebJar for markdown-it-container
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/markdown-it/markdown-it-container

Download markdown-it-container

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/markdown-it-container/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>markdown-it-container</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/markdown-it-container/
implementation 'org.webjars.bower:markdown-it-container:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.bower/markdown-it-container/
implementation ("org.webjars.bower:markdown-it-container:2.0.0")
'org.webjars.bower:markdown-it-container:jar:2.0.0'
<dependency org="org.webjars.bower" name="markdown-it-container" rev="2.0.0">
  <artifact name="markdown-it-container" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='markdown-it-container', version='2.0.0')
)
libraryDependencies += "org.webjars.bower" % "markdown-it-container" % "2.0.0"
[org.webjars.bower/markdown-it-container "2.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

markdown-it-container

Build Status NPM version Coverage Status

Plugin for creating block-level custom containers for markdown-it markdown parser.

v2.+ requires markdown-it v5.+, see changelog.

With this plugin you can create block containers like:

::: warning
*here be dragons*
:::

.... and specify how they should be rendered. If no renderer defined, <div> with container name class will be created:

<div class="warning">
<em>here be dragons</em>
</div>

Markup is the same as for fenced code blocks. Difference is, that marker use another character and content is rendered as markdown markup.

Installation

node.js, browser:

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

API

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

Params:

  • name - container name (mandatory)
  • options:
    • validate - optional, function to validate tail after opening marker, should return true on success.
    • render - optional, renderer function for opening/closing tokens.
    • marker - optional (:), character to use in delimiter.

Example

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

md.use(require('markdown-it-container'), 'spoiler', {

  validate: function(params) {
    return params.trim().match(/^spoiler\s+(.*)$/);
  },

  render: function (tokens, idx) {
    var m = tokens[idx].info.trim().match(/^spoiler\s+(.*)$/);

    if (tokens[idx].nesting === 1) {
      // opening tag
      return '<details><summary>' + md.utils.escapeHtml(m[1]) + '</summary>\n';

    } else {
      // closing tag
      return '</details>\n';
    }
  }
});

console.log(md.render('::: spoiler click me\n*content*\n:::\n'));

// Output:
//
// <details><summary>click me</summary>
// <p><em>content</em></p>
// </details>

License

MIT

org.webjars.bower

Markdown it!

Next generation markdown parser in javascript, with pluggable syntax!

Versions

Version
2.0.0