markdown-it-hashtag
hashtag (
#tag
) plugin for markdown-it markdown parser.
#hashtag
=> <a href="/tags/hashtag" class="tag">#hashtag</a>
Install
node.js, bower:
npm install markdown-it-hashtag --savebower install markdown-it-hashtag --save
Use
Basic
var md = ; md; // => '<p><a href="/tags/hashtag" class="tag">#hashtag</a></p>'
Differences in browser. If you load the script directly into the page, without
package system, module will add itself globally as window.markdownitHashtag
.
Advanced
You can specify the RegExp for hashtags and specify the allowed preceding content. You can also modify the output of the renderer. Here is an example with default values:
var md = ; mdrendererrules { var tagName = tokensidxcontent; return '<a href="/tags/' + tagName + '" class="tag">';} mdrendererrules { return '#' + tokensidxcontent;} mdrendererrules; // => '<p><a href="/tags/hashtag" class="tag">#hashtag</a></p>'