diaspora-style @mention plugin for markdown-it markdown parser.
@{[email protected]}
=> @<a href="/people/1337" class="mention">User Name</a>
@{User Name; [email protected]}
=> @<a href="/people/1337" class="mention">User Name</a>
node.js, bower:
npm install markdown-it-diaspora-mention --save
bower install markdown-it-diaspora-mention --save
var md = require("markdown-it")()
.use(require("markdown-it-diaspora-mention"), {
mentions: [
{
diaspora_id: "[email protected]",
guid: 1337,
name: "Alice Awesome"
},
{
handle: "[email protected]",
url: "/my/awesome/url",
guid: 42,
name: "Foo Bar"
}
],
allowHovercards: true,
currentUserId: 1337
});
md.render("@{User Name; [email protected]}"); // => "@<a href='/people/1337' class='mention'>User Name</a>"
md.render("@{[email protected]}"); // => "@<a href='/people/1337' class='mention'>Alice Awesome</a>"
md.render("@{Foo Bar; [email protected]}"); // => "@<a href='/my/awesome/url' class='mention hovercardable'>Foo Bar</a>"
Differences in the browser. If you load the script directly into the page, without a
package system, the module will add itself globally as window.markdownitDiasporaMention
.