JSPM

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

A `prettier` serializer/stringifier for `unified` ecosystem (rehype/remark/mdx)

Package Exports

  • unified-prettier

Readme

unified-prettier

GitHub Actions Codecov Language grade: JavaScript type-coverage npm GitHub Release

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier changesets

A prettier serializer/stringifier for unified ecosystem (rehype/remark/mdx)

TOC

Usage

Install

# pnpm
pnpm add unified-prettier

# yarn
yarn add unified-prettier

# npm
npm i unified-prettier

CLI

remark --use unified-prettier .

The above command may yield:

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:

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

API

This plugin can also be used with programmatically:

import { unified } from 'unified'
import { prettier } from 'unified-prettier'
import { readSync } from 'to-vfile'

unified()
  .use(prettier, {
    parser: 'markdown', // or `html`, or `mdx`,
    // other `prettier` options
  })
  .process('# Hello World')
  .then(({ messages, value }) => {
    // Formatted content
    console.log(value)

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

// or
unified()
  .use(prettier, {
    // no `parser` required if you're using correct `VFile#path`
    // `prettier` options except parser
  })
  .process(readSync('README.md'))
  .then(({ messages, value }) => {
    // Formatted content
    console.log(value)

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

Acknowledgements

remark-prettier

Sponsors

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Backers

Backers

1stG RxTS UnTS
1stG Open Collective backers and sponsors RxTS Open Collective backers and sponsors UnTS Open Collective backers and sponsors

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG.me