├── .gitignore ├── LICENSE.md ├── README.md ├── package.json └── text-split.js /.gitignore: -------------------------------------------------------------------------------- 1 | bower_components 2 | node_modules 3 | *.log 4 | .DS_Store 5 | bundle.js 6 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2016 Nick Poisson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # text-split 2 | Utility for splitting text into chunks based on regex. 3 | 4 | ##Installation 5 | ``` 6 | $npm install text-split 7 | $import text-split from 'text-split'; 8 | ``` 9 | 10 | 11 | ##Usage 12 | 13 | **html** 14 | ``` 15 |
16 | It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. 17 |
18 | ``` 19 | **javascript** 20 | ``` 21 | const textBox = document.getElementById("text-box"); 22 | text-split(textBox, ', but'); 23 | ``` 24 | 25 | result will look like this 26 | ``` 27 | [ 28 | It has survived not only five centuries, 29 | also the leap into electronic typesetting, remaining essentially unchanged. 30 | ] 31 | ``` 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "text-split", 3 | "version": "1.0.0", 4 | "description": "Utility for splitting text into chunks based on regex.", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "author": { 8 | "name": "Nick Poisson", 9 | "email": "nick@jam3.com", 10 | "url": "nick@jam3.com" 11 | }, 12 | "dependencies": {}, 13 | "devDependencies": { 14 | "tape": "*" 15 | }, 16 | "scripts": { 17 | "test": "node test/test.js" 18 | }, 19 | "keywords": [ 20 | "text,", 21 | "split,", 22 | "regex,", 23 | "array,", 24 | "explode,", 25 | "join" 26 | ], 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/Jam3/text-split.git" 30 | }, 31 | "homepage": "https://github.com/Jam3/text-split", 32 | "bugs": { 33 | "url": "https://github.com/Jam3/text-split/issues" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /text-split.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * This function splits text from innerHTML based on regex. Then, it wrap sparated words with except