@hackmd/markdown-it-regexp
plugin that makes regexp replacement simple
Last updated 3 months ago by yukaii .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @hackmd/markdown-it-regexp 
SYNC missed versions from official npm registry.

markdown-it-regexp

THis is fork version of 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, utils) {
    var url = 'http://example.org/u/' + match[1]

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

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

Current Tags

  • 0.4.1                                ...           latest (3 months ago)

2 Versions

  • 0.4.1                                ...           3 months ago
  • 0.4.0                                ...           3 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |