first commit
This commit is contained in:
21
node_modules/titlecase/LICENCE.md
generated
vendored
Normal file
21
node_modules/titlecase/LICENCE.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
Copyright © 2008–2013 David Gouch. Licensed under the MIT License.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
77
node_modules/titlecase/README.md
generated
vendored
Normal file
77
node_modules/titlecase/README.md
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# David Gouch's String#toTitleCase() for Node.js
|
||||
|
||||
This is a fork of David Gouch's excellent [`String#toTitleCase()`](https://github.com/gouch/to-title-case) method inspired by John Gruber's [post on the topic](http://daringfireball.net/2008/08/title_case_update)
|
||||
|
||||
I've simply taken it off the `String` prototype and exported it from a simple module.
|
||||
|
||||
```js
|
||||
var toTitleCase = require('titlecase')
|
||||
|
||||
console.log(toTitleCase('foo bar baz'))
|
||||
```
|
||||
|
||||
See [Gouch's page](http://individed.com/code/to-title-case/) with inline converter. Also see this excellent **[table of test case results](http://individed.com/code/to-title-case/tests.html)** for different converters.
|
||||
|
||||
In addition, I've added a more comprehensive list of words to not capitalise that includes articles, prepositions and conjunctions (see source files for lists), I'm calling this "lax title case", use it like so:
|
||||
|
||||
|
||||
```js
|
||||
var toLaxTitleCase = require('titlecase').toLaxTitleCase
|
||||
|
||||
console.log(toLaxTitleCase('foo bar baz'))
|
||||
```
|
||||
|
||||
**Using as an executable**
|
||||
|
||||
Install with `npm install titlecase -g` and you'll get a `to-title-case` executable that you can run to titlecase strings:
|
||||
|
||||
```
|
||||
$ to-title-case "what is this thing?"
|
||||
What Is This Thing?
|
||||
```
|
||||
|
||||
*Original README:*
|
||||
|
||||
# To Title Case for JavaScript
|
||||
|
||||
Instructions: Include the to-title-case.js script and use the new .toTitleCase() method on the string you want converted.
|
||||
|
||||
## History
|
||||
### 2.1 / 2013-11-03
|
||||
- Acknowledge characters outside of US-ASCII
|
||||
- Fix bug related to hyphenated small words
|
||||
- Replace baby's first testing script with the QUnit framework
|
||||
|
||||
### 2.0.1 / 2012-01-06
|
||||
|
||||
- Fixed IE 7 breakage introduced in 2.0. Don't treat strings like character arrays.
|
||||
|
||||
### 2.0 / 2012-01-06
|
||||
|
||||
- 15% less code and 35% easier to understand.
|
||||
- Small words list moved to variable for easy modification.
|
||||
- Test titles rewritten to focus on a single issue per title.
|
||||
- More braces to make style guides and JSLint happier.
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2008–2013 David Gouch. Licensed under the MIT License.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
1
node_modules/titlecase/articles.js
generated
vendored
Normal file
1
node_modules/titlecase/articles.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = [ 'the', 'a', 'an', 'some' ]
|
||||
8
node_modules/titlecase/bin.js
generated
vendored
Executable file
8
node_modules/titlecase/bin.js
generated
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var toTitleCase = require('./to-title-case')
|
||||
|
||||
process.argv.slice(2).forEach(function (a) {
|
||||
console.log(toTitleCase(a))
|
||||
})
|
||||
|
||||
11
node_modules/titlecase/conjunctions.js
generated
vendored
Normal file
11
node_modules/titlecase/conjunctions.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = [
|
||||
'as'
|
||||
, 'because'
|
||||
, 'for'
|
||||
, 'and'
|
||||
, 'nor'
|
||||
, 'but'
|
||||
, 'or'
|
||||
, 'yet'
|
||||
, 'so'
|
||||
]
|
||||
22
node_modules/titlecase/package.json
generated
vendored
Normal file
22
node_modules/titlecase/package.json
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "titlecase",
|
||||
"version": "1.1.3",
|
||||
"description": "Intelligently converting strings to title case (an enhanced fork of David Gouch's library)",
|
||||
"main": "to-title-case.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/rvagg/titlecase.git"
|
||||
},
|
||||
"keywords": [
|
||||
"title-case",
|
||||
"title",
|
||||
"case",
|
||||
"gouch",
|
||||
"to-title-case"
|
||||
],
|
||||
"author": "Rod Vagg <rod@vagg.org>",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"to-title-case": "./bin.js"
|
||||
}
|
||||
}
|
||||
109
node_modules/titlecase/prepositions.js
generated
vendored
Normal file
109
node_modules/titlecase/prepositions.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
module.exports = [
|
||||
'a'
|
||||
, 'abaft'
|
||||
, 'aboard'
|
||||
, 'about'
|
||||
, 'above'
|
||||
, 'absent'
|
||||
, 'across'
|
||||
, 'afore'
|
||||
, 'after'
|
||||
, 'against'
|
||||
, 'along'
|
||||
, 'alongside'
|
||||
, 'amid'
|
||||
, 'amidst'
|
||||
, 'among'
|
||||
, 'amongst'
|
||||
, 'an'
|
||||
, 'apropos'
|
||||
, 'apud'
|
||||
, 'around'
|
||||
, 'as'
|
||||
, 'aside'
|
||||
, 'astride'
|
||||
, 'at'
|
||||
, 'athwart'
|
||||
, 'atop'
|
||||
, 'barring'
|
||||
, 'before'
|
||||
, 'behind'
|
||||
, 'below'
|
||||
, 'beneath'
|
||||
, 'beside'
|
||||
, 'besides'
|
||||
, 'between'
|
||||
, 'beyond'
|
||||
, 'but'
|
||||
, 'by'
|
||||
, 'circa'
|
||||
, 'concerning'
|
||||
, 'despite'
|
||||
, 'down'
|
||||
, 'during'
|
||||
, 'except'
|
||||
, 'excluding'
|
||||
, 'failing'
|
||||
, 'following'
|
||||
, 'for'
|
||||
, 'forenenst'
|
||||
, 'from'
|
||||
, 'given'
|
||||
, 'in'
|
||||
, 'including'
|
||||
, 'inside'
|
||||
, 'into'
|
||||
, 'like'
|
||||
, 'mid'
|
||||
, 'midst'
|
||||
, 'minus'
|
||||
, 'modulo'
|
||||
, 'near'
|
||||
, 'next'
|
||||
, 'notwithstanding'
|
||||
, 'o\''
|
||||
, 'of'
|
||||
, 'off'
|
||||
, 'on'
|
||||
, 'onto'
|
||||
, 'opposite'
|
||||
, 'out'
|
||||
, 'outside'
|
||||
, 'over'
|
||||
, 'pace'
|
||||
, 'past'
|
||||
, 'per'
|
||||
, 'plus'
|
||||
, 'pro'
|
||||
, 'qua'
|
||||
, 'regarding'
|
||||
, 'round'
|
||||
, 'sans'
|
||||
, 'save'
|
||||
, 'since'
|
||||
, 'than'
|
||||
, 'through'
|
||||
, 'throughout'
|
||||
, 'thru'
|
||||
, 'thruout'
|
||||
, 'till'
|
||||
, 'times'
|
||||
, 'to'
|
||||
, 'toward'
|
||||
, 'towards'
|
||||
, 'under'
|
||||
, 'underneath'
|
||||
, 'unlike'
|
||||
, 'until'
|
||||
, 'unto'
|
||||
, 'up'
|
||||
, 'upon'
|
||||
, 'versus'
|
||||
, 'via'
|
||||
, 'vice'
|
||||
, 'vis-à-vis'
|
||||
, 'with'
|
||||
, 'within'
|
||||
, 'without'
|
||||
, 'worth'
|
||||
]
|
||||
29
node_modules/titlecase/test/index.html
generated
vendored
Normal file
29
node_modules/titlecase/test/index.html
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>To Title Case</title>
|
||||
<link href="http://code.jquery.com/qunit/qunit-1.12.0.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
|
||||
<script src="../to-title-case.js"></script>
|
||||
<script>
|
||||
(function($){
|
||||
$.getJSON('tests.json', runTests);
|
||||
|
||||
function runTests(testCases) {
|
||||
test('toTitleCase()', function(){
|
||||
$.each(testCases, function(index, testCase){
|
||||
deepEqual(testCase.input.toTitleCase(), testCase.expect,
|
||||
testCase.expect);
|
||||
});
|
||||
});
|
||||
}
|
||||
})(jQuery);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
154
node_modules/titlecase/test/tests.json
generated
vendored
Normal file
154
node_modules/titlecase/test/tests.json
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
[
|
||||
{
|
||||
"input": "follow step-by-step instructions",
|
||||
"expect": "Follow Step-by-Step Instructions"
|
||||
},
|
||||
{
|
||||
"input": "this sub-phrase is nice",
|
||||
"expect": "This Sub-Phrase Is Nice"
|
||||
},
|
||||
{
|
||||
"input": "catchy title: a subtitle",
|
||||
"expect": "Catchy Title: A Subtitle"
|
||||
},
|
||||
{
|
||||
"input": "catchy title: \"a quoted subtitle\"",
|
||||
"expect": "Catchy Title: \"A Quoted Subtitle\""
|
||||
},
|
||||
{
|
||||
"input": "catchy title: “‘a twice quoted subtitle’”",
|
||||
"expect": "Catchy Title: “‘A Twice Quoted Subtitle’”"
|
||||
},
|
||||
{
|
||||
"input": "\"a title inside double quotes\"",
|
||||
"expect": "\"A Title Inside Double Quotes\""
|
||||
},
|
||||
{
|
||||
"input": "all words capitalized",
|
||||
"expect": "All Words Capitalized"
|
||||
},
|
||||
{
|
||||
"input": "small words are for by and of lowercase",
|
||||
"expect": "Small Words Are for by and of Lowercase"
|
||||
},
|
||||
{
|
||||
"input": "a small word starts",
|
||||
"expect": "A Small Word Starts"
|
||||
},
|
||||
{
|
||||
"input": "a small word it ends on",
|
||||
"expect": "A Small Word It Ends On"
|
||||
},
|
||||
{
|
||||
"input": "do questions work?",
|
||||
"expect": "Do Questions Work?"
|
||||
},
|
||||
{
|
||||
"input": "multiple sentences. more than one.",
|
||||
"expect": "Multiple Sentences. More Than One."
|
||||
},
|
||||
{
|
||||
"input": "Ends with small word of",
|
||||
"expect": "Ends With Small Word Of"
|
||||
},
|
||||
{
|
||||
"input": "double quoted \"inner\" word",
|
||||
"expect": "Double Quoted \"Inner\" Word"
|
||||
},
|
||||
{
|
||||
"input": "single quoted 'inner' word",
|
||||
"expect": "Single Quoted 'Inner' Word"
|
||||
},
|
||||
{
|
||||
"input": "fancy double quoted “inner” word",
|
||||
"expect": "Fancy Double Quoted “Inner” Word"
|
||||
},
|
||||
{
|
||||
"input": "fancy single quoted ‘inner’ word",
|
||||
"expect": "Fancy Single Quoted ‘Inner’ Word"
|
||||
},
|
||||
{
|
||||
"input": "this vs. that",
|
||||
"expect": "This vs. That"
|
||||
},
|
||||
{
|
||||
"input": "this vs that",
|
||||
"expect": "This vs That"
|
||||
},
|
||||
{
|
||||
"input": "this v. that",
|
||||
"expect": "This v. That"
|
||||
},
|
||||
{
|
||||
"input": "this v that",
|
||||
"expect": "This v That"
|
||||
},
|
||||
{
|
||||
"input": "address email@example.com titles",
|
||||
"expect": "Address email@example.com Titles"
|
||||
},
|
||||
{
|
||||
"input": "pass camelCase through",
|
||||
"expect": "Pass camelCase Through"
|
||||
},
|
||||
{
|
||||
"input": "don't break",
|
||||
"expect": "Don't Break"
|
||||
},
|
||||
{
|
||||
"input": "catchy title: substance subtitle",
|
||||
"expect": "Catchy Title: Substance Subtitle"
|
||||
},
|
||||
{
|
||||
"input": "we keep NASA capitalized",
|
||||
"expect": "We Keep NASA Capitalized"
|
||||
},
|
||||
{
|
||||
"input": "leave Q&A unscathed",
|
||||
"expect": "Leave Q&A Unscathed"
|
||||
},
|
||||
{
|
||||
"input": "Scott Moritz and TheStreet.com’s million iPhone la-la land",
|
||||
"expect": "Scott Moritz and TheStreet.com’s Million iPhone La-La Land"
|
||||
},
|
||||
{
|
||||
"input": "you have a http://example.com/foo/ title",
|
||||
"expect": "You Have a http://example.com/foo/ Title"
|
||||
},
|
||||
{
|
||||
"input": "your hair[cut] looks (nice)",
|
||||
"expect": "Your Hair[cut] Looks (Nice)"
|
||||
},
|
||||
{
|
||||
"input": "keep that colo(u)r",
|
||||
"expect": "Keep That Colo(u)r"
|
||||
},
|
||||
{
|
||||
"input": "have you read “The Lottery”?",
|
||||
"expect": "Have You Read “The Lottery”?"
|
||||
},
|
||||
{
|
||||
"input": "Read markdown_rules.txt to find out how _underscores around words_ will be interpreted",
|
||||
"expect": "Read markdown_rules.txt to Find Out How _Underscores Around Words_ Will Be Interpreted"
|
||||
},
|
||||
{
|
||||
"input": "Read markdown_rules.txt to find out how *asterisks around words* will be interpreted",
|
||||
"expect": "Read markdown_rules.txt to Find Out How *Asterisks Around Words* Will Be Interpreted"
|
||||
},
|
||||
{
|
||||
"input": "Notes and observations regarding Apple’s announcements from ‘The Beat Goes On’ special event",
|
||||
"expect": "Notes and Observations Regarding Apple’s Announcements From ‘The Beat Goes On’ Special Event"
|
||||
},
|
||||
{
|
||||
"input": "Drink this piña colada while you listen to ænima",
|
||||
"expect": "Drink This Piña Colada While You Listen to Ænima"
|
||||
},
|
||||
{
|
||||
"input": "capitalize hyphenated words on-demand",
|
||||
"expect": "Capitalize Hyphenated Words On-Demand"
|
||||
},
|
||||
{
|
||||
"input": "take them on: special lower cases",
|
||||
"expect": "Take Them On: Special Lower Cases"
|
||||
}
|
||||
]
|
||||
50
node_modules/titlecase/to-title-case.js
generated
vendored
Executable file
50
node_modules/titlecase/to-title-case.js
generated
vendored
Executable file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* To Title Case 2.1 – http://individed.com/code/to-title-case/
|
||||
* Copyright © 2008–2013 David Gouch. Licensed under the MIT License.
|
||||
*
|
||||
* modifications by @rvagg Apr-2014
|
||||
*/
|
||||
|
||||
//String.prototype.toTitleCase = function(){
|
||||
|
||||
|
||||
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
|
||||
|
||||
|
||||
module.exports = function toTitleCase(str){
|
||||
return titleCase(str, smallWords)
|
||||
}
|
||||
|
||||
|
||||
module.exports.toTitleCase = module.exports
|
||||
|
||||
|
||||
var laxWords = require('./articles').concat(require('./prepositions')).concat(require('./conjunctions'))
|
||||
.concat(smallWords.source.replace(/(^\^\(|\)\$$)/g, '').split('|'))
|
||||
.concat(['is']) // a personal preference
|
||||
, laxWordsRe = new RegExp('^(' + laxWords.join('|') + ')$', 'i')
|
||||
|
||||
|
||||
module.exports.toLaxTitleCase = function toLaxTitleCase(str){
|
||||
return titleCase(str, laxWordsRe)
|
||||
}
|
||||
|
||||
|
||||
function titleCase (str, smallWords) {
|
||||
if (!str)
|
||||
return str
|
||||
return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){
|
||||
if (index > 0 && index + match.length !== title.length &&
|
||||
match.search(smallWords) > -1 && title.charAt(index - 2) !== ':' &&
|
||||
(title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
|
||||
title.charAt(index - 1).search(/[^\s-]/) < 0) {
|
||||
return match.toLowerCase();
|
||||
}
|
||||
|
||||
if (match.substr(1).search(/[A-Z]|\../) > -1) {
|
||||
return match;
|
||||
}
|
||||
|
||||
return match.charAt(0).toUpperCase() + match.substr(1);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user