remark-remove-comments
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

remark-remove-comments

Downloads Size version MIT License

Remark plugin to remove HTML comments from the processed output.

Install

This package is ESM only. In Node.js (version 14.14+, or 16.0+, 18.0+, 19.0+), install with npm:

npm install remark-remove-comments

Use

Say we have the following file, example.md:

# Hello World

This is a markdown file, with text in it.

<!-- But in this file there's a comment, like "TODO: fix 😅",
  I don't want this to appear in the HTML output, it's just for me -->

And our script, example.js, looks as follows:

import { readFileSync } from 'node:fs';
import remark from 'remark';
import removeComments from 'remark-remove-comments';

remark()
  .use(removeComments)
  .process(readFileSync('example.md', 'utf-8'), (err, file) => {
    if (err) throw err;
    console.log(String(file));
  });

Now, running node example yields:

# Hello World

This is a markdown file, with text in it.

API

remark().use(removeComments)

Removes every HTML node that matches this regex

License

MIT © https://alvin.codes/

Package Sidebar

Install

npm i remark-remove-comments

Weekly Downloads

5,808

Version

1.1.1

License

MIT

Unpacked Size

5.22 kB

Total Files

7

Last publish

Collaborators

  • alvinometric