JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3865
  • Score
    100M100P100Q124752F
  • License MIT

A unified plugin to format output using Prettier

Package Exports

  • unified-prettier

Readme

unified-prettier

github actions npm version npm downloads codecov prettier

A unified plugin to format output using Prettier.

Table of Contents

Installation

npm install unified-prettier

Usage

This unified plugin takes content from another compiler, and reformats the output using Prettier. It’s intended to work with unified-engine implementations, such as remark-cli and rehype-cli.

In your configuration file file, add unified-prettier to the plugins:

{
  "plugins": ["unified-prettier"]
}

It can also be used programmatically.

The following example formats the readme using Prettier.

import { remark } from 'remark'
import { read } from 'to-vfile'
import unifiedPrettier from 'unified-prettier'

const processor = remark.use(unifiedPrettier)
const file = await read('README.md')

const { value } = await processor.process(file)

console.log(value)

The following package formats the readme using Prettier after updating the table of contents.

import { remark } from 'remark'
import remarkToc from 'remark-toc'
import { read } from 'to-vfile'
import unifiedPrettier from 'unified-prettier'

const processor = remark.use(remarkToc).use(unifiedPrettier)
const file = await read('README.md')

const { value } = await processor.process(file)

console.log(value)

API

The default export is a unified plugin.

Options

This plugin accepts Prettier options. By default it uses the options from the Prettier configuration file.

Acknowledgements

Thanks to @JounQin for giving me the npm package name.

License

MIT © Remco Haszing