Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/3rd-Eden/commenting
Wrap content in a comment that is valid for a given file type.
https://github.com/3rd-Eden/commenting
Last synced: 16 days ago
JSON representation
Wrap content in a comment that is valid for a given file type.
- Host: GitHub
- URL: https://github.com/3rd-Eden/commenting
- Owner: 3rd-Eden
- Created: 2015-08-07T19:13:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-15T11:38:37.000Z (almost 4 years ago)
- Last Synced: 2024-09-23T19:36:26.945Z (about 2 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 7
- Watchers: 3
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# commenting
Commenting is a small module that allows you to wrap text in to a comment format
which is suitable for the supplied extension. This can be useful if you do not
want to trigger content errors for 404 routes on static assets so you can put
your reason inside a comment instead of returning HTML. But it can also be used
a development tool to inject build information in to your files for example.## Installation
Module is released in the public npm registry and can be installed by running:
```
npm install --save commenting
```## Usage
The module exposes a single function as API. This function accepts the text as
string or array as first argument and an options object as last argument. The
following options are supported:- extension: The file extension, which is used to figure out which comment style
should be used.
- style: Override default extension mapping and provide a comment style your
self (should be an object with start, body and end properties which contains
the comment styles).```js
'use strict';var commenting = require('commenting')
, comment;comment = commenting('hello world', { extension: '.js' });
/**
* hello world
*/comment = commenting(['hello', 'world'], { extension: '.jade' });
//
// hello
// world
//
```The following extensions are supported:
- html, html: Uses HTML comments.
- js, css, less, sass: Uses `/**/` style comments
- coffee: Uses `###` style comments.
- jade: Uses `//` style comments.Empty files or extension option with `''` as value is automatically mapped to a
hash `#` based comment style. This is because things like `.npmignore` or
`.gitignore` don't have have extensions that we can track.## License
MIT