+15
-13
| var cheerio = require('cheerio'); | ||
| var set = function (variable, alt) { | ||
| return (variable != undefined) ? variable : alt; | ||
| }; | ||
| module.exports = function(html, plugins, opts){ | ||
| var options = {}; | ||
| if( opts != undefined ){ | ||
| options.normalizeWhitespace = (opts.normalizeWhitespace != undefined) ? opts.normalizeWhitespace : true; | ||
| options.xmlMode = (opts.xmlMode != undefined) ? opts.xmlMode : false; | ||
| options.decodeEntities = (opts.decodeEntities != undefined) ? opts.decodeEntities : false; | ||
| } | ||
| var options = {}; | ||
| options.normalizeWhitespace = set(options.normalizeWhitespace, true); | ||
| options.xmlMode = set(options.xmlMode, false); | ||
| options.decodeEntities = set(options.decodeEntities, false); | ||
| // load | ||
| var $ = cheerio.load(html, options); | ||
| // load | ||
| var $ = cheerio.load(html, options); | ||
| // transform with plugins | ||
| for(var i = 0, len = plugins.length; i < len; i++){ | ||
| plugins[i]($); | ||
| } | ||
| // transform with plugins | ||
| for(var i = 0, len = plugins.length; i < len; i++){ | ||
| plugins[i]($); | ||
| } | ||
| return $.html(); | ||
| return $.html(); | ||
| }; |
+1
-1
| { | ||
| "name": "postxml", | ||
| "version": "0.1.1", | ||
| "version": "0.1.3", | ||
| "description": "Xml transformations", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+4
-0
@@ -46,1 +46,5 @@ # Postxml | ||
| * [postxml-imgalt](https://github.com/postxml/postxml-imgalt) | ||
| * [poxtxml-custom-tags](https://github.com/postxml/poxtxml-custom-tags) | ||
| * [poxtxml-import](https://github.com/postxml/poxtxml-import) | ||
| * [poxtxml-placeholder](https://github.com/postxml/poxtxml-placeholder) | ||
| * [poxtxml-beml](https://github.com/postxml/poxtxml-beml) |
3202
8.32%35
2.94%50
8.7%