Comparing version 1.2.0 to 1.3.0
@@ -0,1 +1,4 @@ | ||
## 1.3.0 | ||
* Add: Serializer `encodeHtmlEntities` option. | ||
## 1.2.0 | ||
@@ -2,0 +5,0 @@ * Add: `<template>` support |
@@ -0,0 +0,0 @@ 'use strict'; |
'use strict'; | ||
var DefaultTreeAdapter = require('../tree_adapters/default'), | ||
Utils = require('../common/utils'), | ||
HTML = require('../common/html'); | ||
@@ -10,2 +11,4 @@ | ||
//Default serializer options | ||
var DEFAULT_OPTIONS = {encodeHtmlEntities: true}; | ||
@@ -19,3 +22,2 @@ //Escaping regexes | ||
//Escape string | ||
@@ -39,2 +41,3 @@ function escapeString(str, attrMode) { | ||
//Enquote doctype ID | ||
@@ -49,4 +52,5 @@ function enquoteDoctypeId(id) { | ||
//Serializer | ||
var Serializer = module.exports = function (treeAdapter) { | ||
var Serializer = module.exports = function (treeAdapter, options) { | ||
this.treeAdapter = treeAdapter || DefaultTreeAdapter; | ||
this.options = Utils.mergeOptions(DEFAULT_OPTIONS, options); | ||
}; | ||
@@ -125,3 +129,4 @@ | ||
for (var i = 0, attrsLength = attrs.length; i < attrsLength; i++) { | ||
var attr = attrs[i]; | ||
var attr = attrs[i], | ||
value = this.options.encodeHtmlEntities ? escapeString(attr.value, true) : attr.value; | ||
@@ -149,3 +154,3 @@ this.html += ' '; | ||
this.html += '="' + escapeString(attr.value, true) + '"'; | ||
this.html += '="' + value + '"'; | ||
} | ||
@@ -165,3 +170,3 @@ }; | ||
else | ||
this.html += escapeString(content, false); | ||
this.html += this.options.encodeHtmlEntities ? escapeString(content, false) : content; | ||
}; | ||
@@ -168,0 +173,0 @@ |
{ | ||
"name": "parse5", | ||
"description": "WHATWG HTML5 specification-compliant, fast and ready for production HTML parsing/serialization toolset for Node.", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"author": "Ivan Nikulin <ifaaan@gmail.com> (https://github.com/inikulin)", | ||
"contributors": [ | ||
"Sebastian Mayr <sebmaster16@gmail.com> (http://blog.smayr.name)", | ||
"Sean Lang <slang800@gmail.com> (http://slang.cx)" | ||
"Sean Lang <slang800@gmail.com> (http://slang.cx)", | ||
"Alan Clarke (https://github.com/alanclarke)" | ||
], | ||
@@ -10,0 +11,0 @@ "homepage": "http://inikulin.github.io/parse5/", |
@@ -165,5 +165,10 @@ <p align="center"> | ||
####• Serializer.ctor([treeAdapter]) | ||
####• Serializer.ctor([treeAdapter, options]) | ||
Creates new reusable instance of the `Serializer`. Optional `treeAdapter` argument specifies input tree format. If `treeAdapter` argument is not specified, `default` tree adapter will be used. | ||
`options` object provides the serialization algorithm modifications (**Warning:** switching default options causes HTML5 specification violation. However, it may be useful in some cases, e.g. markup instrumentation. Use it on your own risk.) | ||
* **options.encodeHtmlEntities** - HTML-encode characters like `<`, `>`, `&`, etc. Default: `true`. | ||
*Example:* | ||
@@ -170,0 +175,0 @@ ```js |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
387146
23
6353
234