Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

gulp-html-rebuild

0.0.4 • Public • Published

gulp-html-rebuild NPM version Build status Coverage Status

Run minodisk/htmlparser2#stack-storage and rebuild html.

Parse and rebuild html to observe coding conventions, and so on.

Install

$ npm install --save-dev gulp-html-rebuild

Usage

var gulp = require('gulp');
var rebuild = require('gulp-html-rebuild');
 
gulp.task('default', function () {
  return gulp.src('index.html')
  .pipe(rebuild({
    onopentag: function (name, attrs) {
      var classes = attrs.class.split(/\s+/);
      var index;
      if ((index = classes.indexOf('article')) === -1) {
        return;
      }
      classes.splice(index, 1);
      attrs.class = classes.join(' ');
      return "<" + name + rebuild.createAttrStr(attrs) + ">";
    }
  }));
});

API

rebuild(options)

Gulp plugin for rebuilding html.

  • Params:
    • options Object - Options for rebuilding html.
      • onprocessinginstruction Function - Replace instruction with returned string. Default: function (name, value) { return "<" + value + ">"; }
      • onopentag Function - Replace open tag with returned string. Default: function (name, attrs) { return "<" + name + createAttrStr(attrs) + ">"; }
      • onclosetag Function - Replace close tag with returned string. Default: function (name, attrs) { return "</" + name + ">"; }
      • ontext Function - Replace text with returned string. Default: function (value) { return value; }
      • oncomment Function - Replace comment with returned string. Default: function (value) { return "<!--" + value + "-->"; }

rebuild.createAttrStr(attrs)

Helper for creating attribute.

  • Params:
    • attrs Object - A map of the attribute.
  • Returns: String - A string of the attribute starting with whitespace.

Install

npm i gulp-html-rebuild

DownloadsWeekly Downloads

2

Version

0.0.4

License

MIT

Last publish

Collaborators

  • avatar