# remark-prettier

> Check and format markdown or MDX using Prettier as a remark plugin

Latest version **2.0.0** (published 2022-08-14) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install remark-prettier
pnpm add remark-prettier
yarn add remark-prettier
bun add remark-prettier
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-08-14 |
| First published | 2021-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14.0.0 |
| Dependencies | 5 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Remco Haszing |
| Maintainers | remcohaszing |
| Keywords | markdown, mdx, prettier, remark, remark-plugin, unified |

## Links

- npm: https://www.npmjs.com/package/remark-prettier
- Repository: https://github.com/remcohaszing/remark-prettier
- Homepage: https://github.com/remcohaszing/remark-prettier#readme
- Issues: https://github.com/remcohaszing/remark-prettier/issues
- Funding: https://github.com/sponsors/remcohaszing
- npm.io page: https://npm.io/package/remark-prettier

## Dependencies (5)

- [@types/mdast](https://npm.io/package/@types/mdast.md) ^3.0.0
- [vfile-location](https://npm.io/package/vfile-location.md) ^4.0.0
- [@types/prettier](https://npm.io/package/@types/prettier.md) ^2.0.0
- [mdast-util-to-markdown](https://npm.io/package/mdast-util-to-markdown.md) ^1.0.0
- [prettier-linter-helpers](https://npm.io/package/prettier-linter-helpers.md) ^1.0.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2022-08-14
- 1.3.0 — 2021-11-02
- 1.2.0 — 2021-03-11
- 1.1.0 — 2021-03-10

## README

# Remark Prettier

[![github actions](https://github.com/remcohaszing/remark-prettier/actions/workflows/ci.yml/badge.svg)](https://github.com/remcohaszing/remark-prettier/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/remcohaszing/remark-prettier/branch/master/graph/badge.svg)](https://codecov.io/gh/remcohaszing/remark-prettier)
[![npm](https://img.shields.io/npm/v/remark-prettier)](https://www.npmjs.com/package/remark-prettier)
[![prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)

Check and format markdown using Prettier as a [remark](https://github.com/remarkjs/remark) plugin

## Installation

`remark-prettier` has a peer dependency on [prettier](https://prettier.io)

```sh
npm install prettier remark-prettier
```

## Usage

By default this plugin does 2 things:

- Report differences from the Prettier formatting.
- Format the document using Prettier.

It has support for Prettier configuration files: `.editorconfig`, `.prettierrc*`, and
`.prettierignore`.

For example, running `remark --use remark-prettier .` may yield:

```sh
README.md
  18:30-19:1  warning  Replace `⏎` with `·`  replace  prettier
        38:1  warning  Insert `⏎`            insert   prettier
  40:32-41:1  warning  Delete `⏎`            delete   prettier
```

This can also be spcified in a `.remarkrc` file:

```json
{
  "plugins": ["remark-prettier"]
}
```

This plugin can also be used with programmatically:

```js
import remark from 'remark';
import remarkPrettier from 'remark-prettier';
import { readSync } from 'to-vfile';

remark()
  .use(remarkPrettier)
  .process(readSync('README.md'))
  .then(({ messages, value }) => {
    // Formatted content
    console.log(value);

    // Prettier formatting violations
    console.dir(messages);
  });
```

`remark-prettier` registers a unified compiler. This means this plugin is used for formatting the
document. Usually this is done by `remark-stringify`. When building a custom unified processor,
`remark-stringify` can be omitted. If multiple compilers are registered, the last one registered is
used.

```js
import remarkParse from 'remark-parse';
import remarkPrettier from 'remark-prettier';
import { readSync } from 'to-vfile';
import unified from 'unified';

unified()
  .use(remarkParse)
  .use(remarkPrettier)
  .process(readSync('README.md'))
  .then(({ messages, value }) => {
    // Formatted content
    console.log(value);

    // Prettier formatting violations
    console.dir(messages);
  });
```

### Options

The first argument may contain the options below. A second argument may specify overrides for the
Prettier configuration, although this isn’t recommended.

## `format`

By default `remark-prettier` registers a unified compiler, which formats the document using
Prettier. This behaviour can be disabled by setting this option to `false`. (Default `true`)

## `report`

By default `remark-prettier` reports differences from document as Prettier would format it. This
behaviour can be disabled by setting this option to `false`. (Default `true`)

## See also

- [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier)
- [prettier](https://prettier.io)
- [remark](https://github.com/remarkjs/remark)
- [stylelint-prettier](https://github.com/prettier/stylelint-prettier)

## License

[MIT](LICENSE.md) © [Remco Haszing](https://github.com/remcohaszing)

---
_Source: https://npm.io/package/remark-prettier · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
