hyphenate method

String hyphenate(
  1. String text
)

Implementation

String hyphenate(String text) {
  var currentWord = StringBuffer();
  var result = new StringBuffer();

  for (int i = 0; i < text.length; i++) {
    final c = text[i];

    if (c.isLetter) {
      currentWord.write(c);
    } else {
      if (currentWord.length > 0) {
        result.write(hyphenateWord(currentWord.toString()));
        currentWord.clear();
      }
      result.write(c);
    }
  }

  result.write(hyphenateWord(currentWord.toString()));

  return result.toString();
}