fsmaia / remark-remove-comments

Remark plugin to remove HTML comments from the processed output

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

remark-remove-comments

Downloads Size

Remark plugin to remove HTML comments from the processed output.

Install

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:

const fs = require('fs');
const remark = require('remark');
const removeComments = require('remark-remove-comments');

remark()
  .use(removeComments)
  .process(fs.readFileSync('example.md', 'utf-8'), function (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 comments.

License

MIT © https://alvin.codes/

About

Remark plugin to remove HTML comments from the processed output

License:MIT License


Languages

Language:JavaScript 100.0%