2.0.0 • Published 5 months ago

remark-tight-comments v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Black Lives Matter! Last commit timestamp Codecov Source license Monthly Downloads NPM version Uses Semantic Release!

remark-tight-comments

This is a unified (remark) plugin that allows you to selectively remove unnecessary newlines around Markdown comments.

This plugin is useful for preserving the structure of auto-generated content, e.g. all-contributors, doctoc, etc. You might also be interested in remark-ignore, which lets you instruct remark not to transform parts of your Markdown documents. For a live example of these two plugins in action, check the source of this very README.md file. ✨


Install

Due to the nature of the unified ecosystem, this package is ESM only and cannot be require'd.

npm install --save-dev remark-tight-comments

Usage

Via API

import { read } from 'to-vfile';
import { remark } from 'remark';
import remarkTightComments from 'remark-tight-comments';

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

console.log(String(file));

Via remark-cli

remark -o --use tight-comments README.md

Via unified configuration

In package.json:

  /* … */
  "remarkConfig": {
    "plugins": [
      "remark-tight-comments"
      /* … */
    ]
  },
  /* … */

In .remarkrc.js:

module.exports = {
  plugins: [
    // …
    'tight-comments'
  ]
};

In .remarkrc.mjs:

import remarkTightComments from 'remark-tight-comments';

export default {
  plugins: [
    // …
    remarkTightComments
  ]
};

API

Detailed interface information can be found under docs/.

Examples

See mdast-util-tight-comments for example outputs.

Related

Contributing and Support

New issues and pull requests are always welcome and greatly appreciated! 🤩 Just as well, you can star 🌟 this project to let me know you found it useful! ✊🏿 Thank you!

See CONTRIBUTING.md and SUPPORT.md for more information.

Contributors

See the table of contributors.