Skip to content

Commit

Permalink
Add remark-autolink-references
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Nov 14, 2020
1 parent 9ae5435 commit 6e36fda
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [Usage](#usage)
- [Package Options](#package-options)
- [`ignore`](#ignore)
- [`autolinkReferences`](#autolinkreferences)
- [`changelog`](#changelog)
- [`validateLinks`](#validatelinks)
- [`paddedTable`](#paddedtable)
Expand Down Expand Up @@ -180,6 +181,37 @@ Alternatively, for use in non-node projects, place a `.hallmarkrc` file in the w

A string or array of files to ignore. Merged with `--ignore / -i` if any.

### `autolinkReferences`

Autolink custom references [like GitHub Pro](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuring-autolinks-to-reference-external-resources) does. Must be an object with a `prefix` and `url` (if `autolinkReferences` is not set, this feature does nothing). For example, given:

```json
{
"autolinkReferences": {
"prefix": "JIRA-",
"url": "https://example.atlassian.net/browse/JIRA-<num>"
}
}
```

Then `hallmark fix` will transform:

```md
### Fixed

- Prevent infinite loop (JIRA-4275)
```

To:

```md
### Fixed

- Prevent infinite loop ([JIRA-4275](https://example.atlassian.net/browse/JIRA-4275))
```

While `hallmark lint` will warn about unlinked references.

### `changelog`

An object containing options to be passed to [`remark-changelog`](https://github.com/vweevers/remark-changelog):
Expand Down
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ function hallmark (options, callback) {
[require('remark-changelog'), { cwd, fix, pkg, repository, ...changelog }],
[require('remark-github'), { repository }],

// Does nothing unless configured
rc.autolinkReferences
? [require('remark-autolink-references'), {
...rc.autolinkReferences,
fix
}]
: null,

// TODO: https://github.com/vweevers/hallmark/issues/36
toc ? [require('remark-toc'), { tight: true }] : null,
toc ? [require('remark-collapse'), collapseToc()] : null,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"find-file-up": "^2.0.1",
"github-url-from-git": "^1.5.0",
"remark": "^12.0.1",
"remark-autolink-references": "^1.0.0",
"remark-changelog": "^1.2.0",
"remark-collapse": "~0.1.2",
"remark-git-contributors": "^3.0.0",
Expand Down

0 comments on commit 6e36fda

Please sign in to comment.