Skip to content

Files

Latest commit

921ed94 Β· Nov 30, 2023

History

History

remark-tight-comments

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 28, 2023
Nov 28, 2023
Nov 28, 2023
Nov 30, 2023
Oct 20, 2022
Jan 29, 2023
Nov 30, 2023
Oct 20, 2022
Oct 20, 2022
Jan 29, 2023

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));
remark -o --use tight-comments README.md

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.