Auto-link references to commits, issues, pull-requests, and users like GitHub: Writing on GitHub.
npm install mdast-githubcomponent install wooorm/mdast-githubbower install mdast-githubvar github = require('wooorm/mdast-github');UMD: globals, AMD, and CommonJS (uncompressed and compressed):
<script src="path/to/mdast.js"></script> <script src="path/to/mdast-github.js"></script> <script> mdast.use(mdastGitHub); </script>Dependencies:
var github = require('mdast-github'); var mdast = require('mdast').use(github);Input:
var input = [ '* SHA: a5c3785ed8d6a35868bc169f07e40e889087fd2e', '* User@SHA: jlord@a5c3785ed8d6a35868bc169f07e40e889087fd2e', '* User/Repository@SHA: jlord/sheetsee.js@a5c3785e', '* #Num: #26', '* GH-Num: GH-26', '* User#Num: jlord#26', '* User/Repository#Num: jlord/sheetsee.js#26', '* @mention', '* And @mentioning someone else', '* And nothing.' ].join('\n');Process:
var doc = mdast.process(input);Yields:
- SHA: [a5c3785](https://github.com/wooorm/mdast-github/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e) - User@SHA: [jlord@a5c3785](https://github.com/jlord/mdast-github/commit/a5c3785ed8d6a35868bc169f07e40e889087fd2e) - User/Repository@SHA: [jlord/sheetsee.js@a5c3785](https://github.com/jlord/sheetsee.js/commit/a5c3785e) - #Num: [#26](https://github.com/wooorm/mdast-github/issues/26) - GH-Num: [GH-26](https://github.com/wooorm/mdast-github/issues/26) - User#Num: [jlord#26](https://github.com/jlord/mdast-github/issues/26) - User/Repository#Num: [jlord/sheetsee.js#26](https://github.com/jlord/sheetsee.js/issues/26) - [@mention](https://github.com/blog/821) - And [@mentioning](https://github.com/mentioning) someone else - And nothing.Adds references to commits, issues, pull-requests, and users similar to how GitHub renders these in issues, comments, and pull request descriptions.
-
SHA commits references:
e2c1dc7690932b0cef900fa4e7355df093448341— e2c1dc7 -
User@SHA:
wooorm@e2c1dc7690932b0cef900fa4e7355df093448341— wooorm@e2c1dc7 -
User/Repository@SHA:
wooorm/mdast-github@e2c1dc7690932b0cef900fa4e7355df093448341— wooorm/mdast-github@e2c1dc7 -
Hash-Num:
#1— #1 -
GH-Num:
GH-1— GH-1 -
User#Num:
wooorm#1— wooorm#1 -
User/Repository#Num:
wooorm/mdast-github#1— wooorm/mdast-github#1
These links are generated relative to a project. In Node this is auto-detected by loading package.json and looking for a repository field. In the browser, or when overwriting this, you can pass a repository to mdast.use.