posthtml-parser
Advanced tools
Comparing version 0.3.3 to 0.4.0
17
index.js
@@ -28,2 +28,16 @@ 'use strict'; | ||
function isDirective(directive, tag) { | ||
if (directive.name instanceof RegExp) { | ||
var regex = RegExp(directive.name.source, 'i'); | ||
return regex.test(tag); | ||
} | ||
if (tag !== directive.name) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
function parserDirective(name, data) { | ||
@@ -37,3 +51,4 @@ var directives = [].concat(defaultDirectives, options.directives || []); | ||
if (name.toLowerCase() === directive.name) { | ||
name = name.toLowerCase(); | ||
if (isDirective(directive, name)) { | ||
if (!last) { | ||
@@ -40,0 +55,0 @@ results.push(directiveText); |
{ | ||
"name": "posthtml-parser", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "Parse HTML/XML to PostHTMLTree", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -85,3 +85,3 @@ # posthtml-parser | ||
Default: `[{name: '!doctype', start: '<', end: '>'}]` | ||
Description: *Adds processing of custom directives* | ||
Description: *Adds processing of custom directives. Note: The property ```name``` in custom directives can be ```String``` or ```RegExp``` type* | ||
@@ -88,0 +88,0 @@ ## License |
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
26309
118