}
current++;
- string attr_value = text ('"');
+ string attr_value = text ('"', false);
if (current >= end || current[0] != '"') {
// error
space ();
if (current[0] != '<') {
- content = text ('<');
+ content = text ('<', true);
} else {
// no text
// read next token
return type;
}
- string text (char end_char) {
+ string text (char end_char, bool rm_trailing_whitespace) {
StringBuilder content = new StringBuilder ();
char* text_begin = current;
char* last_linebreak = current;
column += (int) (current - last_linebreak);
+ // Removes trailing whitespace
+ if (rm_trailing_whitespace) {
+ char* str_pos = ((char*)content.str) + content.len;
+ for (str_pos--; str_pos > ((char*)content.str) && str_pos[0].isspace(); str_pos--);
+ content.erase ((ssize_t) (str_pos-((char*) content.str) + 1), -1);
+ }
+
return content.str;
}