It is a tool for transforming html/xml with JS plugins based on cheerio.
npm i postxml --save-dev
var postxml = require('postxml');
var cheerioOptions = {};
var output = postxml([
require('postxml-plugin')(pluginOptions)
])
.process('<div class="b-block"></div>', cheerioOptions);
);
Use gulp-postxml
var postxml = require('gulp-postxml');
var postxmlPlugins = [
require('postxml-plugin')(pluginOptions)
];
var cheerioOptions = {};
gulp.task('html', function () {
gulp.src('index.htm')
.pipe(postxml(postxmlPlugins, cheerioOptions))
.pipe(gulp.dest('out'));
})
Transform html with plugins
Add plugin
- postxml-amp - converts plain HTML to Google Accelerated Mobile Pages (AMP)
- postxml-beml - BEML plugin
- postxml-custom-tags
- postxml-image-size - adds sizes to images
- postxml-imgalt
- postxml-import
- postxml-import-styles - replace
<link>
with<style>
and import css-code - postxml-markdown - add classes (bem) to
markdown
html tags - postxml-ng-valid - replace
ng-
withdata-ng
- postxml-placeholder
- postxml-remove - removes elements by query selectors
- postxml-repeat - repeat elements
- postxml-wrap - wrap with emmet abbreviation
- postxml-inline-data - replace images and files with data uri
- postxml-template - added template for postxml-repeat
- postxml-lazyload - shortcut syntax for lazyload
- postxml-prefix - add prefix to all classes
- postxml-size - shortcut width & height
- postxml-variables - html variables