Socket
Socket
Sign inDemoInstall

posthtml-parser

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posthtml-parser - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

coverage/base.css

29

index.js

@@ -11,2 +11,4 @@ 'use strict';

var defaultDirectives = [{name: '!doctype', start: '<', end: '>'}];
/**

@@ -26,8 +28,24 @@ * Parse html to PostHTMLTree

function parserDirective(name, data) {
var directives = options.directives || defaultDirectives;
var last = bufArray.last();
for (var i = 0; i < directives.length; i++) {
var directive = directives[i];
var directiveText = directive.start + data + directive.end;
if (name.toLowerCase() === directive.name) {
if (!last) {
results.push(directiveText);
return;
}
last.content || (last.content = []);
last.content.push(directiveText);
}
}
}
var parser = new htmlparser.Parser({
onprocessinginstruction: function(name, data) {
if (name.toLowerCase() === '!doctype') {
results.push('<' + data + '>');
}
},
onprocessinginstruction: parserDirective,
oncomment: function(data) {

@@ -106,1 +124,2 @@ var comment = '<!--' + data + '-->',

module.exports.defaultOptions = defaultOptions;
module.exports.defaultDirectives = defaultDirectives;

2

package.json
{
"name": "posthtml-parser",
"version": "0.2.1",
"version": "0.3.0",
"description": "Parse HTML/XML to PostHTMLTree",

@@ -5,0 +5,0 @@ "keywords": [

@@ -80,4 +80,11 @@ # posthtml-parser

## Options
### `directives`
Type: `Array`
Default: `[{name: '!doctype', start: '<', end: '>'}]`
Description: *Adds processing of custom directives*
## License
[MIT](LICENSE)
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