Ticket #30966: 30966.11.patch
File 30966.11.patch, 2.5 KB (added by , 6 years ago) 


src/wpadmin/js/wordcount.js
14 14 WordCounter.prototype.settings = { 15 15 HTMLRegExp: /<\/?[az][^>]*?>/gi, 16 16 spaceRegExp: /  /gi, 17 removeRegExp: /[09.(),;:!?%#$¿'"_+=\\\/]+/g, 17 connectorRegExp: /\u2014/gi, 18 removeRegExp: new RegExp( [ 19 '[', 20 // Basic Latin (extract) 21 '\u0021\u0040\u005B\u0060\u007B\u007E', 22 // Latin1 Supplement (extract) 23 '\u0080\u00BF\u00D7\u00F7', 24 // General Punctuation 25 // Superscripts and Subscripts 26 // Currency Symbols 27 // Combining Diacritical Marks for Symbols 28 // Letterlike Symbols 29 // Number Forms 30 // Arrows 31 // Mathematical Operators 32 // Miscellaneous Technical 33 // Control Pictures 34 // Optical Character Recognition 35 // Enclosed Alphanumerics 36 // Box Drawing 37 // Block Elements 38 // Geometric Shapes 39 // Miscellaneous Symbols 40 // Dingbats 41 // Miscellaneous Mathematical SymbolsA 42 // Supplemental ArrowsA 43 // Braille Patterns 44 // Supplemental ArrowsB 45 // Miscellaneous Mathematical SymbolsB 46 // Supplemental Mathematical Operators 47 // Miscellaneous Symbols and Arrows 48 '\u2000\u2BFF', 49 // Supplemental Punctuation 50 '\u2E00\u2E7F', 51 ']' 52 ].join( '' ), 'g' ), 18 53 wordsRegExp: /\S\s+/g, 19 54 charactersRegExp: /\S/g, 20 55 allRegExp: /[^\f\n\r\t\v\u00ad\u2028\u2029]/g, … … 31 66 32 67 text = text.replace( this.settings.HTMLRegExp, '\n' ); 33 68 text = text.replace( this.settings.spaceRegExp, ' ' ); 34 text = text.replace( this.settings.removeRegExp, '' ); 69 70 if ( type === 'words' ) { 71 text = text.replace( this.settings.connectorRegExp, ' ' ); 72 text = text.replace( this.settings.removeRegExp, '' ); 73 } 35 74 36 75 text = text.match( this.settings[ type + 'RegExp' ] ); 37 76 
tests/qunit/wpadmin/js/wordcount.js
35 35 message: 'Punctuation.', 36 36 string: 'It\'s two three... 4?', 37 37 words: 3, 38 characters: 11, 38 characters: 17, 39 all: 20 40 }, 41 { 42 message: 'Em dash.', 43 string: 'one\u2014twothree', 44 words: 3, 45 characters: 14, 39 46 all: 14 40 47 } 41 48 ], function( test ) {