commonform-regexp-annotator
Advanced tools
Comparing version 1.0.3 to 1.1.0
14
index.js
@@ -11,6 +11,12 @@ var predicate = require('commonform-predicate') | ||
.forEach(function(expression) { | ||
var match = expression.exec(element) | ||
if (match !== null) { | ||
annotations.push( | ||
annotator(form, elementPath, expression, match)) } }) } | ||
var match | ||
if (expression.global) { | ||
while ((match = expression.exec(element)) !== null) { | ||
annotations.push( | ||
annotator(form, elementPath, expression, match)) } } | ||
else { | ||
match = expression.exec(element) | ||
if (match !== null) { | ||
annotations.push( | ||
annotator(form, elementPath, expression, match)) } } }) } | ||
return annotations }, | ||
@@ -17,0 +23,0 @@ [ ]) } |
{ | ||
"name": "commonform-regexp-annotator", | ||
"description": "create Common Form annotators from lists of regular expressions", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (http://kemitchell.com)", | ||
@@ -6,0 +6,0 @@ "devDependencies": { |
@@ -7,3 +7,3 @@ The module exports a single function that takes an array of `RegExp` and a function for generating annotations and returns an annotator function to apply to Common Forms. | ||
var expressions = [ | ||
new RegExp('\\b(apple)\\b', 'i'), | ||
new RegExp('\\b(apple(s?))\\b', 'gi'), | ||
/\b(thereof)\b/ ] | ||
@@ -19,3 +19,3 @@ ``` | ||
message: ( | ||
match[1] === 'apple' ? | ||
( match[1].indexOf('apple') > -1 ) ? | ||
( '"' + word + '" is fruity' ) : | ||
@@ -38,7 +38,11 @@ ( '"' + word + '" is archaic' ) ), | ||
assert.deepEqual( | ||
annotator({ content: [ 'Drop that apple and the stem thereof!' ] }), | ||
[ { message: '"apple" is fruity', | ||
annotator({ content: [ 'Drop them apples and the apple stem thereof!' ] }), | ||
[ { message: '"apples" is fruity', | ||
path: [ 'content', 0 ], | ||
source: 'example-annotator', | ||
url: null }, | ||
{ message: '"apple" is fruity', | ||
path: [ 'content', 0 ], | ||
source: 'example-annotator', | ||
url: null }, | ||
{ message: '"thereof" is archaic', | ||
@@ -45,0 +49,0 @@ path: [ 'content', 0 ], |
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
4006
42
50