mirror of
https://github.com/gabemart/hipku.git
synced 2025-01-18 12:05:35 +00:00
Better way to capitalize haiku
This commit is contained in:
parent
8768da7339
commit
cf65e8bdfd
25
dist/hipku.js
vendored
25
dist/hipku.js
vendored
@ -264,7 +264,7 @@ function writeHaiku(wordArray, ipv6) {
|
||||
/*
|
||||
** Capitalize appropriate words
|
||||
*/
|
||||
schema = capitalizeHaiku(schema, nonWords);
|
||||
schema = capitalizeHaiku(schema);
|
||||
haiku = schema.join('');
|
||||
|
||||
return haiku;
|
||||
@ -351,7 +351,7 @@ function getSchema(ipv6, octet) {
|
||||
return [schema, nonWords];
|
||||
}
|
||||
|
||||
function capitalizeHaiku(haikuArray, nonWords) {
|
||||
function capitalizeHaiku(haikuArray) {
|
||||
var period = '.';
|
||||
|
||||
/*
|
||||
@ -361,34 +361,15 @@ function capitalizeHaiku(haikuArray, nonWords) {
|
||||
|
||||
for (var i = 1; i < haikuArray.length; i++) {
|
||||
|
||||
if (haikuArray[i] === period) {
|
||||
var isWord;
|
||||
|
||||
if (haikuArray[i] === period && i + 2 < haikuArray.length) {
|
||||
/*
|
||||
** If the current entry is a period then the next entry will be
|
||||
** a newLine or a space, so check two positions ahead and
|
||||
** capitalize that entry, so long as it's a word
|
||||
*/
|
||||
|
||||
isWord = true;
|
||||
|
||||
if (haikuArray[i + 2] === undefined ||
|
||||
haikuArray[i + 2] === null ||
|
||||
haikuArray[i + 2] === '') {
|
||||
isWord = false;
|
||||
}
|
||||
|
||||
for (var j = 0; j < nonWords.length; j++) {
|
||||
if (haikuArray[i + 2] === nonWords[j]) {
|
||||
isWord = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isWord) {
|
||||
haikuArray[i + 2] = capitalizeWord(haikuArray[i + 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return haikuArray;
|
||||
}
|
||||
|
25
index.js
25
index.js
@ -264,7 +264,7 @@ function writeHaiku(wordArray, ipv6) {
|
||||
/*
|
||||
** Capitalize appropriate words
|
||||
*/
|
||||
schema = capitalizeHaiku(schema, nonWords);
|
||||
schema = capitalizeHaiku(schema);
|
||||
haiku = schema.join('');
|
||||
|
||||
return haiku;
|
||||
@ -351,7 +351,7 @@ function getSchema(ipv6, octet) {
|
||||
return [schema, nonWords];
|
||||
}
|
||||
|
||||
function capitalizeHaiku(haikuArray, nonWords) {
|
||||
function capitalizeHaiku(haikuArray) {
|
||||
var period = '.';
|
||||
|
||||
/*
|
||||
@ -361,34 +361,15 @@ function capitalizeHaiku(haikuArray, nonWords) {
|
||||
|
||||
for (var i = 1; i < haikuArray.length; i++) {
|
||||
|
||||
if (haikuArray[i] === period) {
|
||||
var isWord;
|
||||
|
||||
if (haikuArray[i] === period && i + 2 < haikuArray.length) {
|
||||
/*
|
||||
** If the current entry is a period then the next entry will be
|
||||
** a newLine or a space, so check two positions ahead and
|
||||
** capitalize that entry, so long as it's a word
|
||||
*/
|
||||
|
||||
isWord = true;
|
||||
|
||||
if (haikuArray[i + 2] === undefined ||
|
||||
haikuArray[i + 2] === null ||
|
||||
haikuArray[i + 2] === '') {
|
||||
isWord = false;
|
||||
}
|
||||
|
||||
for (var j = 0; j < nonWords.length; j++) {
|
||||
if (haikuArray[i + 2] === nonWords[j]) {
|
||||
isWord = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isWord) {
|
||||
haikuArray[i + 2] = capitalizeWord(haikuArray[i + 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return haikuArray;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user