README.md
1# pug-strip-comments
2
3Strips comments from Pug token stream
4
5[](https://travis-ci.org/pugjs/pug-strip-comments)
6[](https://david-dm.org/pugjs/pug?path=packages/pug-strip-comments)
7[](https://david-dm.org/pugjs/pug?path=packages/pug-strip-comments&type=dev)
8[](https://www.npmjs.org/package/pug-strip-comments)
9
10## Installation
11
12 npm install pug-strip-comments
13
14## Usage
15
16```js
17var lex = require('pug-lexer');
18var stripComments = require('pug-strip-comments');
19
20var tokens = lex('//- unbuffered\n// buffered');
21// [ { type: 'comment', line: 1, val: ' unbuffered', buffer: false },
22// { type: 'newline', line: 2 },
23// { type: 'comment', line: 2, val: ' buffered', buffer: true },
24// { type: 'eos', line: 2 } ]
25
26// Only strip unbuffered comments (default)
27stripComments(tokens, { filename: 'pug' });
28// [ { type: 'newline', line: 2 },
29// { type: 'comment', line: 2, val: ' buffered', buffer: true },
30// { type: 'eos', line: 2 } ]
31
32// Only strip buffered comments (when you want to play a joke on your coworkers)
33stripComments(tokens, { filename: 'pug', stripUnbuffered: false, stripBuffered: true });
34// [ { type: 'comment', line: 1, val: ' unbuffered', buffer: false },
35// { type: 'newline', line: 2 },
36// { type: 'eos', line: 2 } ]
37
38// Strip both (if you want Pug VERY clean)
39stripComments(tokens, { filename: 'pug', stripBuffered: true });
40// [ { type: 'newline', line: 2 },
41// { type: 'eos', line: 2 } ]
42```
43
44## License
45
46MIT
47