escape method
Escape and return a portion of buffer.
See isEscaped for a description of what is considered an escaped character.
escape takes the portion of buffer between start
(inclusive) and end
(exclusive) and
replaces each pair of escaping character and escaped character with just the escaped
character.
Implementation
String escape(int start, int end) {
String raw = buffer.substring(start, end);
int currentIndex = start;
return raw.split('').fold('', (ret, s) {
currentIndex++;
if (isEscaped(currentIndex)) {
return ret;
}
return ret + s;
});
}