New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

markdown-it-comment

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-comment

typescript-template

latest
npmnpm
Version
2.0.2
Version published
Maintainers
1
Created
Source

markdown-it-comment

NPM version

Plugin for creating custom comment for markdown-it markdown parser.

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

With this plugin you can create comments like:

[here be content]{here be comment}

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

<span class="content">here be content</span>
<span class="comment">here be comment</span>

Installation

node.js, browser:

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

API

const md = require('markdown-it')()
  .use(require('markdown-it-comment')[,options])

Params:

  • options:
    • renderContent - optional, renderer function for opening/closing content tokens.
    • renderComment - optional, renderer function for opening/closing comment tokens.

Example

const md = require('markdown-it')()

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

  renderContentDefault(tokens, idx, _options, env, slf) {
    if (tokens[idx].nesting === 1)
      tokens[idx].attrJoin('class', 'content')

    return slf.renderToken(tokens, idx, _options, env, slf)
  },

  renderCommentDefault(tokens, idx, _options, env, slf) {
    if (tokens[idx].nesting === 1)
      tokens[idx].attrJoin('class', 'comment')

    return slf.renderToken(tokens, idx, _options, env, slf)
  }
})

console.log(md.render('hello [world]{this is a comment}'))

// Output:
// <p>hello <span class="content">world</span>
// <span class="comment">this is a comment</span></p>

Demo

https://peterroe.github.io/markdown-it-comment/

License

MIT

Keywords

typescript

FAQs

Package last updated on 06 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts