unified

Project: remarkjs/remark-contributors

Package: remark-contributors@6.0.1

  1. Dependents: 6
  2. remark plugin to inject a given list of contributors into a table
  1. remark 187
  2. unified 175
  3. plugin 136
  4. markdown 132
  5. mdast 85
  6. remark-plugin 68
  7. contributors 2
  8. generation 2
  9. inject 2

remark-contributors

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to inject a given list of contributors into a table.

Note!

This plugin is ready for the new parser in remark (micromark, see remarkjs/remark#536). No change is needed: it works exactly the same now as it did before! (note that remark-gfm must be used as well to support tables)

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install remark-contributors

Use

Say we have the following file, example.md:

# Example

Some text.

## Contributors

## License

MIT

And our script, example.js, looks as follows:

import {readSync} from 'to-vfile'
import {remark} from 'remark'
import remarkContributors from 'remark-contributors'

const file = readSync('example.md')

remark()
  .use(remarkContributors)
  .process(file)
  .then((file) => {
    console.log(String(file))
  })

Now, running node example yields:

# Example

Some text.

## Contributors

| Name                | Website                     |
| ------------------- | --------------------------- |
| **Hugh Kennedy**    | <https://hughsk.io>         |
| **Titus Wormer**    | <https://wooorm.com>        |
| **Vincent Weevers** | <https://vincentweevers.nl> |
| **Nick Baugh**      | <https://niftylettuce.com>  |

## License

MIT

API

This package exports no identifiers. The default export is remarkContributors.

unified().use(remarkContributors[, options])

Inject a given list of contributors.

Options
options.contributors

List of contributors to inject (Array.<Object>). Defaults to the contributors field in the closest package.json upwards from the processed file, if there is one. Supports the string form (name <email> (url)) as well. Fails if no contributors are found or given.

options.align

Alignment to use for all cells in the table (left, right, center, default: null).

options.appendIfMissing

Inject the section if there is none (boolean, default: false).

options.heading

Heading to look for (string (case-insensitive) or RegExp, default: 'contributors').

options.formatters

Map of fields found in contributors to formatters (Object.<Formatter>). These given formatters extend the default formatters.

The keys in formatters should correspond directly (case-sensitive) to keys in contributors.

The values can be:

Formatters have the following properties:

Notes

Security

options.contributors (or contributors in package.json) is used and injected into the tree when given or found. Data in those lists is formatted by options.formatters. If a user has access to either, this could open you up to a cross-site scripting (XSS) attack.

This may become a problem if the Markdown later transformed to rehype (hast) or opened in an unsafe Markdown viewer.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

Contributors

NameWebsite
Hugh Kennedyhttps://hughsk.io
Titus Wormerhttps://wooorm.com
Vincent Weevershttps://vincentweevers.nl
Nick Baughhttps://niftylettuce.com

License

MIT © Hugh Kennedy