@traptitech/markdown-it-regexp
TypeScript icon, indicating that this package has built-in type declarations

0.5.3 • Public • Published

@traptitech/markdown-it-regexp

Forked from https://github.com/rlidwka/markdown-it-regexp

Make simple markdown-it plugins easier.

Usage:

var MD     = require('markdown-it')
var Plugin = require('markdown-it-regexp')

var plugin = Plugin(
  // regexp to match
  /@(\w+)/,

  // this function will be called when something matches
  function(match) {
    var url = 'http://example.org/u/' + match[1]

    return '<a href="' + md.utils.escape(url) + '">'
         + md.utils.escape(match[1])
         + '</a>'
  }
)

var md = MD()
  .use(plugin)
  .render("hello @user")

// prints out:
// <p>hello <a href="http://example.org/u/user">user</a></p>

Live demo as jsfiddle.

Fair warning:

  1. it could be slower than you expect
  2. it is a draft, breaking changes might happen

Readme

Keywords

Package Sidebar

Install

npm i @traptitech/markdown-it-regexp

Weekly Downloads

20

Version

0.5.3

License

MIT

Unpacked Size

4.97 kB

Total Files

7

Last publish

Collaborators

  • trapsysad
  • hijiki51
  • sapphi-red