Linkify GitHub issue references
npm install linkify-issues> Linkify GitHub issue references
``sh`
npm install linkify-issues
`js
import {linkifyIssuesToHtml} from 'linkify-issues';
linkifyIssuesToHtml('Fixes #143 and avajs/ava#1023', {
user: 'sindresorhus',
repository: 'dofle',
attributes: {
class: 'unicorn',
multiple: ['a', 'b'],
number: 1,
exclude: false,
include: true
}
});
//=> 'Fixes #143 and avajs/ava#1023'
`
`js
import {linkifyIssuesToMarkdown} from 'linkify-issues';
linkifyIssuesToMarkdown('Fixes #143 and avajs/ava#1023', {
user: 'sindresorhus',
repository: 'dofle'
});
//=> 'Fixes #143 and avajs/ava#1023'
`
`js
import {linkifyIssuesToDom} from 'linkify-issues';
const fragment = linkifyIssuesToDom('See #143', {
user: 'sindresorhus',
repository: 'dofle',
attributes: {
class: 'unicorn',
}
});
document.body.appendChild(fragment);
`
Returns an HTML string like 'See #143'.
#### string
Type: string
A string with issue references to linkify.
#### options
Type: object
##### user
Required\
Type: string
GitHub user.
##### repository
Required\
Type: string
GitHub repository.
##### attributes
Type: object
HTML attributes to add to the link.
##### baseUrl
Type: string\'https://github.com'
Default:
The base URL.
##### additionalPrefix
Type: string | undefined\'GH-'
Default:
Additional reference prefix to support. It can be set to undefined to disable the default.
`js`
linkifyIssuesToHtml('Will not linkify GH-123', {
user: 'sindresorhus',
repository: 'dofle',
additionalPrefix: undefined
});
// => 'Will not linkify GH-123'
`js`
linkifyIssuesToHtml('Will link SOUP:235 but not GH-123', {
user: 'sindresorhus',
repository: 'dofle',
additionalPrefix: 'SOUP:'
});
// => 'Will link SOUP:235 but not GH-123'
> [!NOTE]
> The prefix is added unescaped to the regex, keep it simple.
Returns a Markdown string like 'See #143'.
#### string
Type: string
A string with issue references to linkify.
#### options
See options above.
Returns a DocumentFragment ready to be appended in a DOM safely, like DocumentFragment(TextNode('See '), HTMLAnchorElement('#143'))`.
This only works in the browser.
#### options
See options above.
- issue-regex - Regular expression for matching issue references
- linkify-urls - Linkify URLs in text