Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parse5

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse5 - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

lib/common/utils.js

3

CHANGELOG.md

@@ -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';

15

lib/serialization/serializer.js
'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">

####&bull; Serializer.ctor([treeAdapter])
####&bull; 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc