Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alvinometric/remark-remove-comments
Remove HTML comments in the processed markdown output
https://github.com/alvinometric/remark-remove-comments
markdown remark
Last synced: about 1 month ago
JSON representation
Remove HTML comments in the processed markdown output
- Host: GitHub
- URL: https://github.com/alvinometric/remark-remove-comments
- Owner: alvinometric
- License: mit
- Created: 2022-06-18T15:35:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-18T21:59:38.000Z (about 1 year ago)
- Last Synced: 2024-09-19T14:38:53.140Z (2 months ago)
- Topics: markdown, remark
- Language: JavaScript
- Homepage:
- Size: 80.1 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# remark-remove-comments
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![version](https://img.shields.io/npm/v/remark-remove-comments.svg?style=flat-square)](https://www.npmjs.com/package/remark-remove-comments)
[![MIT License](https://img.shields.io/npm/l/remark-remove-comments.svg?style=flat-square)](https://github.com/alvinometric/remark-remove-comments/blob/main/LICENSE)[**Remark**](https://github.com/remarkjs/remark) plugin to remove HTML comments from the processed output.
## Install
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
In Node.js (version 14.14+, or 16.0+, 18.0+, 19.0+), install with [npm](https://docs.npmjs.com/cli/install):```sh
npm install remark-remove-comments
```## Use
Say we have the following file, `example.md`:
```markdown
# Hello WorldThis is a markdown file, with text in it.
```
And our script, `example.js`, looks as follows:
```js
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:
```markdown
# Hello WorldThis is a markdown file, with text in it.
```## API
### `remark().use(removeComments)`
Removes every HTML node that matches [this regex](https://github.com/stevemao/html-comment-regex)
## License
[MIT](LICENSE) © https://alvin.codes/
[downloads-badge]: https://img.shields.io/npm/dm/remark-remove-comments.svg?style=flat-square
[downloads]: https://www.npmjs.com/package/remark-remove-comments
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-remove-comments.svg?style=flat-square
[size]: https://bundlephobia.com/result?p=remark-remove-comments