0.2.4 • Published 9 years ago
remarkable-regexp v0.2.4
Make simple remarkable plugins easier.
Usage:
var Remarkable = require('remarkable')
var Plugin = require('remarkable-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>'
}
)
new Remarkable()
.use(plugin)
.render("hello @user")
// prints out:
// <p>hello <a href="http://example.org/u/user">user</a></p>
Fair warning:
- it could be slower than you expect
- it is a draft, breaking changes might happen