hexo/node_modules/pug-strip-comments
jkjoy 9a9cb42f53 20231003 update 2023-10-03 11:14:36 +08:00
..
CHANGELOG.md 20231003 update 2023-10-03 11:14:36 +08:00
LICENSE.md 20231003 update 2023-10-03 11:14:36 +08:00
README.md 20231003 update 2023-10-03 11:14:36 +08:00
index.js 20231003 update 2023-10-03 11:14:36 +08:00
package.json 20231003 update 2023-10-03 11:14:36 +08:00

README.md

pug-strip-comments

Strips comments from Pug token stream

Build Status Dependencies Status DevDependencies Status NPM version

Installation

npm install pug-strip-comments

Usage

var lex = require('pug-lexer');
var stripComments = require('pug-strip-comments');

var tokens = lex('//- unbuffered\n// buffered');
// [ { type: 'comment', line: 1, val: ' unbuffered', buffer: false },
//   { type: 'newline', line: 2 },
//   { type: 'comment', line: 2, val: ' buffered', buffer: true },
//   { type: 'eos', line: 2 } ]

// Only strip unbuffered comments (default)
stripComments(tokens, { filename: 'pug' });
// [ { type: 'newline', line: 2 },
//   { type: 'comment', line: 2, val: ' buffered', buffer: true },
//   { type: 'eos', line: 2 } ]

// Only strip buffered comments (when you want to play a joke on your coworkers)
stripComments(tokens, { filename: 'pug', stripUnbuffered: false, stripBuffered: true });
// [ { type: 'comment', line: 1, val: ' unbuffered', buffer: false },
//   { type: 'newline', line: 2 },
//   { type: 'eos', line: 2 } ]

// Strip both (if you want Pug VERY clean)
stripComments(tokens, { filename: 'pug', stripBuffered: true });
// [ { type: 'newline', line: 2 },
//   { type: 'eos', line: 2 } ]

License

MIT