Auto-link references to commits, issues, pull-requests, and users like GitHub: Writing on GitHub.
npm:
npm install remark-github
remark-github is also available for duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.
Dependencies:
var github = require('remark-github');
var remark = require('remark').use(github);
Input:
var input = [
'* SHA: 1f2a4fb8f88a0a98ea9d0c0522cd538a9898f921',
'* User@SHA: jlord@1f2a4fb8f88a0a98ea9d0c0522cd538a9898f921',
'* User/Repository@SHA: jlord/sheetsee.js@1f2a4fb',
'* #Num: #1',
'* GH-Num: GH-1',
'* User#Num: jlord#1',
'* User/Repository#Num: jlord/sheetsee.js#1',
'* @mention',
'* And @mentioning someone else',
'* And nothing'
].join('\n');
Process:
var doc = remark.process(input);
Yields:
- SHA: [`1f2a4fb`](https://github.com/wooorm/remark-github/commit/1f2a4fb8f88a0a98ea9d0c0522cd538a9898f921)
- User@SHA: [jlord@`1f2a4fb`](https://github.com/jlord/remark-github/commit/1f2a4fb8f88a0a98ea9d0c0522cd538a9898f921)
- User/Repository@SHA: [jlord/sheetsee.js@`1f2a4fb`](https://github.com/jlord/sheetsee.js/commit/1f2a4fb)
- \#Num: [#1](https://github.com/wooorm/remark-github/issues/1)
- GH-Num: [GH-1](https://github.com/wooorm/remark-github/issues/1)
- User#Num: [jlord#1](https://github.com/jlord/remark-github/issues/1)
- User/Repository#Num: [jlord/sheetsee.js#1](https://github.com/jlord/sheetsee.js/issues/1)
- [**@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:
1f2a4fb8f88a0a98ea9d0c0522cd538a9898f921
—1f2a4fb
-
User@SHA:
wooorm@1f2a4fb8f88a0a98ea9d0c0522cd538a9898f921
— wooorm@1f2a4fb
-
User/Repository@SHA:
wooorm/remark-github@1f2a4fb8f88a0a98ea9d0c0522cd538a9898f921
— wooorm/remark-github@1f2a4fb
-
Hash-Num:
#1
— #1 -
GH-Num:
GH-1
— GH-1 -
User#Num:
wooorm#1
— wooorm#1 -
User/Repository#Num:
wooorm/remark-github#1
— wooorm/remark-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
remark.use
.