handle whitespace around attribute symbols

This commit is contained in:
Adam D. Ruppe 2018-06-25 19:37:08 -04:00
parent b0d21de148
commit b351656398
1 changed files with 17 additions and 9 deletions

18
dom.d
View File

@ -406,9 +406,13 @@ class Document : FileResource {
throw new MarkupException(format("char %d (line %d): %s", pos, getLineNumber(pos), message));
}
void eatWhitespace() {
while(pos < data.length && (data[pos] == ' ' || data[pos] == '\n' || data[pos] == '\t' || data[pos] == '\r'))
bool eatWhitespace() {
bool ateAny = false;
while(pos < data.length && (data[pos] == ' ' || data[pos] == '\n' || data[pos] == '\t' || data[pos] == '\r')) {
pos++;
ateAny = true;
}
return ateAny;
}
string readTagName() {
@ -999,7 +1003,9 @@ class Document : FileResource {
string attrName = readAttributeName();
string attrValue = attrName;
eatWhitespace;
bool ateAny = eatWhitespace();
if(strict && ateAny)
throw new MarkupException("inappropriate whitespace after attribute name");
if(pos >= data.length) {
if(strict)
@ -1012,11 +1018,13 @@ class Document : FileResource {
if(data[pos] == '=') {
pos++;
eatWhitespace;
ateAny = eatWhitespace();
if(strict && ateAny)
throw new MarkupException("inappropriate whitespace after attribute equals");
attrValue = readAttributeValue();
eatWhitespace;
eatWhitespace();
}
blankValue: