public String indent(final String str) {
    boolean wasNL = false;
    int indent = 0;
    final StringBuilder sb = new StringBuilder();
    for(final char c : str.toCharArray()) {
      final boolean isNL = NL.indexOf(c) >= 0;
      if(c == out) {
        indent -= width;
      }
      if(wasNL && !isNL) {
        doIndent(sb, indent);
      }
      if(c == in) {
        indent += width;
      }
      sb.append(c);
      wasNL = isNL;
    }
    return sb.toString();
  }