Ticket #30966: 30966.11.patch
File 30966.11.patch, 2.5 KB (added by , 9 years ago) |
---|
-
src/wp-admin/js/word-count.js
14 14 WordCounter.prototype.settings = { 15 15 HTMLRegExp: /<\/?[a-z][^>]*?>/gi, 16 16 spaceRegExp: / | /gi, 17 removeRegExp: /[0-9.(),;:!?%#$¿'"_+=\\\/-]+/g, 17 connectorRegExp: /--|\u2014/gi, 18 removeRegExp: new RegExp( [ 19 '[', 20 // Basic Latin (extract) 21 '\u0021-\u0040\u005B-\u0060\u007B-\u007E', 22 // Latin-1 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 Symbols-A 42 // Supplemental Arrows-A 43 // Braille Patterns 44 // Supplemental Arrows-B 45 // Miscellaneous Mathematical Symbols-B 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/wp-admin/js/word-count.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\u2014two--three', 44 words: 3, 45 characters: 14, 39 46 all: 14 40 47 } 41 48 ], function( test ) {