unified

Project: remarkjs/remark-license

Package: remark-license@6.1.0

  1. Dependents: 0
  2. remark plugin to generate a license section
  1. remark 214
  2. unified 181
  3. markdown 154
  4. plugin 140
  5. mdast 88
  6. remark-plugin 82
  7. text 19
  8. plain 4

remark-license

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to generate a license section.

Contents

What is this?

This package is a unified (remark) plugin to generate a license section such as the one at the bottom of this readme.

When should I use this?

This project is useful when you’re writing documentation for an open source project, typically a Node.js package, that has one or more readmes and maybe some other markdown files as well. You want to show the author and license associated with the project. When this plugin is used, authors can add a certain heading (say, ## License) to documents and this plugin will populate them.

Install

This package is ESM only. In Node.js (version 16+), install with npm:

npm install remark-license

In Deno with esm.sh:

import remarkLicense from 'https://esm.sh/remark-license@7'

In browsers with esm.sh:

<script type="module">
  import remarkLicense from 'https://esm.sh/remark-license@7?bundle'
</script>

Use

Say we have the following file example.md in this project:

# Example

Some text.

## Use

## API

## License

…and a module example.js:

import {remark} from 'remark'
import remarkLicense from 'remark-license'
import {read} from 'to-vfile'

const file = await remark()
  .use(remarkLicense)
  .process(await read('example.md'))

console.log(String(file))

Now running node example.js yields:

# Example

Some text.

## Use

## API

## License

[MIT](license) © [Titus Wormer](https://wooorm.com)

👉 Note: This info is inferred from this project’s package.json and license file. Running this example in a different package will yield different results.

API

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

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

Generate a license section.

Parameters
Returns

Transform (Transformer).

Options

Configuration (TypeScript type).

Fields

Types

This package is fully typed with TypeScript. It exports the additional type Options.

Compatibility

Projects maintained by the unified collective are compatible with maintained versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, remark-license@^7, compatible with Node.js 16.

This plugin works with unified version 6+ and remark version 7+.

Security

options.url (or author.url in package.json) is used and injected into the tree when it’s given or found. This could open you up to a cross-site scripting (XSS) attack if you pass user provided content in or store user provided content in package.json.

This may become a problem if the markdown is 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.

License

MIT © Titus Wormer