react-htmlcontent
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -30,4 +30,2 @@ "use strict"; | ||
var _lruMemoize = _interopRequireDefault(require("lru-memoize")); | ||
var containsHtmlPatt = /(<[A-z]+[^>]*>)(.*?)(<\/[A-z]+>)/g; | ||
@@ -44,3 +42,3 @@ var replaceHtmlContentPatt = /([^<]*)(\s?<[A-z]+[^>]*>)([\s\S]*?)\s?(<\/[A-z]+>\s?)([^<]*)/gi; | ||
if (containsHtmlPatt.test(body)) { | ||
return enhanceTypoInHTML(body); | ||
return _enhanceTypo(body); | ||
} else { | ||
@@ -58,3 +56,3 @@ return (0, _typography.default)(beforeTag, locale, config) + (beforeTag.lastIndexOf(' ') === beforeTag.length - 1 ? ' ' : '') + startTag + (0, _typography.default)(body, locale, config) + endTag + (0, _typography.default)(afterTag, locale, config); | ||
var enhanceTypo = (0, _lruMemoize.default)(50)(_enhanceTypo); | ||
var enhanceTypo = _enhanceTypo; | ||
/** | ||
@@ -61,0 +59,0 @@ * Component for displaying HTML content |
{ | ||
"name": "react-htmlcontent", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "React HTMLContent Component", | ||
@@ -51,5 +51,3 @@ "repository": { | ||
}, | ||
"dependencies": { | ||
"lru-memoize": "1.1.0" | ||
}, | ||
"dependencies": {}, | ||
"main": "dist/index.js", | ||
@@ -56,0 +54,0 @@ "engines": { |
@@ -5,3 +5,6 @@ import fixTypos from '../src/typography' | ||
describe('Existing handling', () => { | ||
let testCase = { 'Nejsme lišáci. S námi vždy víte, kolik a za co platíte. A pokud se k půjčce vztahují nějaké poplatky, nikdy vás nepřekvapí.': 'Nejsme lišáci. S námi vždy víte, kolik a za co platíte. A pokud se k půjčce vztahují nějaké poplatky, nikdy vás nepřekvapí.'} | ||
let testCase = { | ||
'Nejsme lišáci. S námi vždy víte, kolik a za co platíte. A pokud se k půjčce vztahují nějaké poplatky, nikdy vás nepřekvapí.': | ||
'Nejsme lišáci. S námi vždy víte, kolik a za co platíte. A pokud se k půjčce vztahují nějaké poplatky, nikdy vás nepřekvapí.', | ||
} | ||
@@ -17,3 +20,2 @@ Object.keys(testCase).forEach(key => { | ||
let testCase = { | ||
/* | ||
@@ -25,7 +27,9 @@ We are using temporary {variables} in curly brackets as text replacement | ||
'{{test-variable}}': '{{test-variable}}', | ||
'{{test-variable}} at the beginning of the sentence.': '{{test-variable}} at the beginning of the sentence.', | ||
'And {{test-variable}} in the middle of the sentence.': 'And {{test-variable}} in the middle of the sentence.', | ||
'{{test-variable}} at the beginning of the sentence.': | ||
'{{test-variable}} at the beginning of the sentence.', | ||
'And {{test-variable}} in the middle of the sentence.': | ||
'And {{test-variable}} in the middle of the sentence.', | ||
} | ||
Object.keys(testCase).forEach((key) => { | ||
Object.keys(testCase).forEach(key => { | ||
it('', () => { | ||
@@ -39,3 +43,2 @@ assert.equal(fixTypos(key, 'en-us'), testCase[key]) | ||
let testCase = { | ||
/* | ||
@@ -66,7 +69,7 @@ Exceptions | ||
// test order of replacements | ||
'www.tota.sk and 127.0.0.1 and mail@domain.com': 'www.tota.sk and 127.0.0.1 and mail@domain.com', | ||
'www.tota.sk and 127.0.0.1 and mail@domain.com': | ||
'www.tota.sk and 127.0.0.1 and mail@domain.com', | ||
} | ||
Object.keys(testCase).forEach((key) => { | ||
Object.keys(testCase).forEach(key => { | ||
it('', () => { | ||
@@ -80,5 +83,5 @@ assert.equal(fixTypos(key, 'en-us'), testCase[key]) | ||
let testCase = { | ||
// double quoutes | ||
'English „English„ „English„ English': 'English “English” “English” English', | ||
'English „English„ „English„ English': | ||
'English “English” “English” English', | ||
'He said: "Here’s a 12" record."': 'He said: “Here’s a 12″ record.”', | ||
@@ -94,7 +97,7 @@ // ellipsis | ||
"Let's test this: “however, 'quote this or nottin' 'n' this will be corrected for 69'ers,' he said”": | ||
'Let’s test this: “however, ‘quote this or nottin’ ’n’ this will be corrected for 69’ers,’ he said”', | ||
'Let’s test this: “however, ‘quote this or nottin’ ’n’ this will be corrected for 69’ers,’ he said”', | ||
"I'''m": 'I’m', | ||
"I''''m": 'I’m', | ||
"He said: “What about 'name' and 'other name'?”": | ||
'He said: “What about ‘name’ and ‘other name’?”', | ||
'He said: “What about ‘name’ and ‘other name’?”', | ||
@@ -129,8 +132,7 @@ // section sign | ||
// case | ||
'CMSko': 'CMSko', | ||
'cAPSLOCK': 'capslock', | ||
CMSko: 'CMSko', | ||
cAPSLOCK: 'capslock', | ||
} | ||
Object.keys(testCase).forEach((key) => { | ||
Object.keys(testCase).forEach(key => { | ||
it('', () => { | ||
@@ -144,3 +146,2 @@ assert.equal(fixTypos(key, 'en-us'), testCase[key]) | ||
let testCase = { | ||
/* | ||
@@ -150,9 +151,10 @@ Selected combination of rules that may clash. | ||
// Will it remove extra punctuation or will it keep the abbreviation as expected? | ||
'We will continue tomorrow at 8:00 a.m.!': 'We will continue tomorrow at 8:00 a.m.!', | ||
'We will continue tomorrow at 8:00 a.m.!': | ||
'We will continue tomorrow at 8:00 a.m.!', | ||
// Will it remove extra dot? | ||
'We will continue tomorrow at 8:00 a.m..': 'We will continue tomorrow at 8:00 a.m.', | ||
'We will continue tomorrow at 8:00 a.m..': | ||
'We will continue tomorrow at 8:00 a.m.', | ||
} | ||
Object.keys(testCase).forEach((key) => { | ||
Object.keys(testCase).forEach(key => { | ||
it('', () => { | ||
@@ -159,0 +161,0 @@ assert.equal(fixTypos(key, 'en-us'), testCase[key]) |
@@ -26,3 +26,3 @@ import { | ||
'Ťa tvoja': 'Ťa tvoja', | ||
'ja nejsem on': 'ja nejsem on', | ||
'ja nejsem on': 'ja nejsem on', | ||
} | ||
@@ -32,3 +32,6 @@ | ||
it('unit test', () => { | ||
assert.equal(removeNbspBetweenMultiCharWords(key, new Locale('en-us')), testCase[key]) | ||
assert.equal( | ||
removeNbspBetweenMultiCharWords(key, new Locale('en-us')), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -43,11 +46,11 @@ it('module test', () => { | ||
let testCase = { | ||
'Koniec. V potoku': 'Koniec. V potoku', | ||
'Skáče o tyči': 'Skáče o tyči', | ||
'v obchode a v hospode': 'v obchode a v hospode', | ||
'v a v a v': 'v a v a v', | ||
'a з коминів': 'a з коминів', | ||
'a я іду здоїти': 'a я іду здоїти', | ||
'a в хырбетї': 'a в хырбетї', | ||
'што є му вытыкане': 'што є му вытыкане', | ||
'ся ї не': 'ся ї не', | ||
'Koniec. V potoku': 'Koniec. V potoku', | ||
'Skáče o tyči': 'Skáče o tyči', | ||
'v obchode a v hospode': 'v obchode a v hospode', | ||
'v a v a v': 'v a v a v', | ||
'a з коминів': 'a з коминів', | ||
'a я іду здоїти': 'a я іду здоїти', | ||
'a в хырбетї': 'a в хырбетї', | ||
'што є му вытыкане': 'што є му вытыкане', | ||
'ся ї не': 'ся ї не', | ||
'client’s customer': 'client’s customer', // false positive | ||
@@ -58,3 +61,6 @@ } | ||
it('unit test', () => { | ||
assert.equal(addNbspAfterPreposition(key, new Locale('en-us')), testCase[key]) | ||
assert.equal( | ||
addNbspAfterPreposition(key, new Locale('en-us')), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -69,3 +75,3 @@ it('module test', () => { | ||
let testCase = { | ||
'Bed & Breakfast': 'Bed & Breakfast', | ||
'Bed & Breakfast': 'Bed & Breakfast', | ||
} | ||
@@ -75,3 +81,6 @@ | ||
it('unit test', () => { | ||
assert.equal(addNbspAfterAmpersand(key, new Locale('en-us')), testCase[key]) | ||
assert.equal( | ||
addNbspAfterAmpersand(key, new Locale('en-us')), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -86,4 +95,4 @@ it('module test', () => { | ||
let testCase = { | ||
'5 mm': '5 mm', | ||
'5 Kč': '5 Kč', | ||
'5 mm': '5 mm', | ||
'5 Kč': '5 Kč', | ||
} | ||
@@ -93,3 +102,6 @@ | ||
it('unit test', () => { | ||
assert.equal(addNbspAfterCardinalNumber(key, new Locale('en-us')), testCase[key]) | ||
assert.equal( | ||
addNbspAfterCardinalNumber(key, new Locale('en-us')), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -104,8 +116,8 @@ it('module test', () => { | ||
let testCase = { | ||
'1st amendment': '1st amendment', | ||
'2nd amendment': '2nd amendment', | ||
'3rd amendment': '3rd amendment', | ||
'4th amendment': '4th amendment', | ||
'18th amendment': '18th amendment', | ||
'15th March': '15th March', | ||
'1st amendment': '1st amendment', | ||
'2nd amendment': '2nd amendment', | ||
'3rd amendment': '3rd amendment', | ||
'4th amendment': '4th amendment', | ||
'18th amendment': '18th amendment', | ||
'15th March': '15th March', | ||
} | ||
@@ -115,3 +127,6 @@ | ||
it('unit test', () => { | ||
assert.equal(addNbspAfterOrdinalNumber(key, new Locale('en-us')), testCase[key]) | ||
assert.equal( | ||
addNbspAfterOrdinalNumber(key, new Locale('en-us')), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -126,8 +141,8 @@ it('moduel test', () => { | ||
let testCase = { | ||
'1. dodatok': '1. dodatok', | ||
'1.dodatok': '1. dodatok', | ||
'1.štava': '1. štava', | ||
'1. dodatok': '1. dodatok', | ||
'1.dodatok': '1. dodatok', | ||
'1.štava': '1. štava', | ||
'10.00': '10.00', // false positive for the example above | ||
'12. dodatok': '12. dodatok', | ||
'12. január': '12. január', | ||
'12. dodatok': '12. dodatok', | ||
'12. január': '12. január', | ||
} | ||
@@ -137,5 +152,14 @@ | ||
it('unit test', () => { | ||
assert.equal(addNbspAfterOrdinalNumber(key, new Locale('sk')), testCase[key]) | ||
assert.equal(addNbspAfterOrdinalNumber(key, new Locale('cs')), testCase[key]) | ||
assert.equal(addNbspAfterOrdinalNumber(key, new Locale('rue')), testCase[key]) | ||
assert.equal( | ||
addNbspAfterOrdinalNumber(key, new Locale('sk')), | ||
testCase[key], | ||
) | ||
assert.equal( | ||
addNbspAfterOrdinalNumber(key, new Locale('cs')), | ||
testCase[key], | ||
) | ||
assert.equal( | ||
addNbspAfterOrdinalNumber(key, new Locale('rue')), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -152,4 +176,4 @@ it('module test', () => { | ||
let testCase = { | ||
'12. 1. 2017': '12. 1. 2017', | ||
'12.1.2017': '12. 1. 2017', | ||
'12. 1. 2017': '12. 1. 2017', | ||
'12.1.2017': '12. 1. 2017', | ||
'10.00': '10.00', // false positive for the example above | ||
@@ -160,5 +184,14 @@ } | ||
it('unit test', () => { | ||
assert.equal(addNbspWithinOrdinalDate(key, new Locale('sk')), testCase[key]) | ||
assert.equal(addNbspWithinOrdinalDate(key, new Locale('cs')), testCase[key]) | ||
assert.equal(addNbspWithinOrdinalDate(key, new Locale('rue')), testCase[key]) | ||
assert.equal( | ||
addNbspWithinOrdinalDate(key, new Locale('sk')), | ||
testCase[key], | ||
) | ||
assert.equal( | ||
addNbspWithinOrdinalDate(key, new Locale('cs')), | ||
testCase[key], | ||
) | ||
assert.equal( | ||
addNbspWithinOrdinalDate(key, new Locale('rue')), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -175,10 +208,10 @@ it('module test', () => { | ||
let testCase = { | ||
'III. kapitola': 'III. kapitola', | ||
'III.kapitola': 'III. kapitola', | ||
'X. ročník': 'X. ročník', | ||
'V. ročník': 'V. ročník', | ||
'L. ročník': 'L. ročník', | ||
'D. ročník': 'D. ročník', | ||
'8. V. 1945': '8. V. 1945', | ||
'8. V.1945': '8. V. 1945', | ||
'III. kapitola': 'III. kapitola', | ||
'III.kapitola': 'III. kapitola', | ||
'X. ročník': 'X. ročník', | ||
'V. ročník': 'V. ročník', | ||
'L. ročník': 'L. ročník', | ||
'D. ročník': 'D. ročník', | ||
'8. V. 1945': '8. V. 1945', | ||
'8. V.1945': '8. V. 1945', | ||
} | ||
@@ -188,5 +221,14 @@ | ||
it('unit test', () => { | ||
assert.equal(addNbspAfterRomanNumeral(key, new Locale('sk')), testCase[key]) | ||
assert.equal(addNbspAfterRomanNumeral(key, new Locale('cs')), testCase[key]) | ||
assert.equal(addNbspAfterRomanNumeral(key, new Locale('rue')), testCase[key]) | ||
assert.equal( | ||
addNbspAfterRomanNumeral(key, new Locale('sk')), | ||
testCase[key], | ||
) | ||
assert.equal( | ||
addNbspAfterRomanNumeral(key, new Locale('cs')), | ||
testCase[key], | ||
) | ||
assert.equal( | ||
addNbspAfterRomanNumeral(key, new Locale('rue')), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -203,4 +245,4 @@ it('module test', () => { | ||
let testCase = { | ||
'Philip K. Dick': 'Philip K. Dick', | ||
'F. X. Šalda': 'F. X. Šalda', | ||
'Philip K. Dick': 'Philip K. Dick', | ||
'F. X. Šalda': 'F. X. Šalda', | ||
} | ||
@@ -220,4 +262,4 @@ | ||
let testCase = { | ||
'©2017': '© 2017', | ||
'Company ©2017': 'Company © 2017', | ||
'©2017': '© 2017', | ||
'Company ©2017': 'Company © 2017', | ||
} | ||
@@ -227,3 +269,6 @@ | ||
it('just unit tests', () => { | ||
assert.equal(addNbspAfterSymbol(key, new Locale('en-us'), '©'), testCase[key]) | ||
assert.equal( | ||
addNbspAfterSymbol(key, new Locale('en-us'), '©'), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -235,5 +280,5 @@ }) | ||
let testCase = { | ||
'Company © 2017': 'Company © 2017', | ||
'Company © 2017': 'Company © 2017', // hairSpace | ||
'Company © 2017': 'Company © 2017', // narrowNbsp | ||
'Company © 2017': 'Company © 2017', | ||
'Company © 2017': 'Company © 2017', // hairSpace | ||
'Company © 2017': 'Company © 2017', // narrowNbsp | ||
} | ||
@@ -243,3 +288,6 @@ | ||
it('just unit tests', () => { | ||
assert.equal(replaceSpacesWithNbspAfterSymbol(key, new Locale('en-us'), '©'), testCase[key]) | ||
assert.equal( | ||
replaceSpacesWithNbspAfterSymbol(key, new Locale('en-us'), '©'), | ||
testCase[key], | ||
) | ||
}) | ||
@@ -252,18 +300,18 @@ }) | ||
// as all abbreviations can be used within different languages, such as reference, they're being corrected in each language | ||
'č.5 žije': 'č. 5 žije', | ||
'Č.5 žije': 'č. 5 žije', | ||
'č. 5 žije': 'č. 5 žije', | ||
'áno, č. 5 žije': 'áno, č. 5 žije', | ||
'preč č. 5 žije': 'preč č. 5 žije', | ||
'str. 8': 'str. 8', | ||
'tzv. rýč': 'tzv. rýč', | ||
'č.5 žije': 'č. 5 žije', | ||
'Č.5 žije': 'č. 5 žije', | ||
'č. 5 žije': 'č. 5 žije', | ||
'áno, č. 5 žije': 'áno, č. 5 žije', | ||
'preč č. 5 žije': 'preč č. 5 žije', | ||
'str. 8': 'str. 8', | ||
'tzv. rýč': 'tzv. rýč', | ||
'Prines kvetináč. 5 je super číslo.': 'Prines kvetináč. 5 je super číslo.', // false positive | ||
'hl. m. Praha': 'hl. m. Praha', | ||
// "hl.m.Praha" : "hl. m. Praha", // 2 consequetive abbreviations are not supported yet | ||
// "hl. m.Praha" : "hl. m. Praha", | ||
// "hl.m. Praha" : "hl. m. Praha", | ||
'hl. m. Praha': 'hl. m. Praha', | ||
// "hl.m.Praha" : "hl. m. Praha", // 2 consequetive abbreviations are not supported yet | ||
// "hl. m.Praha" : "hl. m. Praha", | ||
// "hl.m. Praha" : "hl. m. Praha", | ||
'10 a.m.': '10 a.m.', // false positive for abbreviation within abbreviation, i.e. m. within a.m. | ||
'e.g. something': 'e.g. something', | ||
'e.g. something': 'e.g. something', | ||
'10 p.': '10 p.', | ||
'pp. 10–25': 'pp. 10–25', | ||
'pp. 10–25': 'pp. 10–25', | ||
'(e.g.)': '(e.g.)', | ||
@@ -277,5 +325,8 @@ '“e.g.”': '“e.g.”', | ||
it('unit tests', () => { | ||
assert.equal(addNbspAfterAbbreviation(key, new Locale('en-us')), testCase[key]) | ||
assert.equal( | ||
addNbspAfterAbbreviation(key, new Locale('en-us')), | ||
testCase[key], | ||
) | ||
}) | ||
}) | ||
}) |
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
1126770
1
2841
- Removedlru-memoize@1.1.0
- Removedlru-memoize@1.1.0(transitive)