Skip to content

Instantly share code, notes, and snippets.

View stevoland's full-sized avatar

Stephen J. Collings stevoland

View GitHub Profile
@stevoland
stevoland / hyphenateLongWords.js
Created September 12, 2012 09:45
Hyphenate long words
/**
* Add a soft hypen (­) to any words in the string longer than the given character length
*
* @param {string} str Input string
* @param {int} maxWordSize Max character length of a word
* @param {int} minFragmentSize [optional] Minimum chars to leave after a hyphen
* @return {string}
*/
var hyphenateLongWords = function (str, maxWordSize, minFragmentSize) {
// TODO: Find out char codes of word break chars