mirror of https://github.com/adamdruppe/arsd.git
fix #168 patch by WebFreak001
This commit is contained in:
parent
506e06091e
commit
677acce81e
20
dom.d
20
dom.d
|
@ -408,7 +408,7 @@ class Document : FileResource {
|
||||||
|
|
||||||
bool eatWhitespace() {
|
bool eatWhitespace() {
|
||||||
bool ateAny = false;
|
bool ateAny = false;
|
||||||
while(pos < data.length && (data[pos] == ' ' || data[pos] == '\n' || data[pos] == '\t' || data[pos] == '\r')) {
|
while(pos < data.length && data[pos].isSimpleWhite) {
|
||||||
pos++;
|
pos++;
|
||||||
ateAny = true;
|
ateAny = true;
|
||||||
}
|
}
|
||||||
|
@ -419,8 +419,7 @@ class Document : FileResource {
|
||||||
// remember to include : for namespaces
|
// remember to include : for namespaces
|
||||||
// basically just keep going until >, /, or whitespace
|
// basically just keep going until >, /, or whitespace
|
||||||
auto start = pos;
|
auto start = pos;
|
||||||
while( data[pos] != '>' && data[pos] != '/' &&
|
while(data[pos] != '>' && data[pos] != '/' && !data[pos].isSimpleWhite)
|
||||||
data[pos] != ' ' && data[pos] != '\n' && data[pos] != '\t' && data[pos] != '\r')
|
|
||||||
{
|
{
|
||||||
pos++;
|
pos++;
|
||||||
if(pos == data.length) {
|
if(pos == data.length) {
|
||||||
|
@ -441,8 +440,7 @@ class Document : FileResource {
|
||||||
// remember to include : for namespaces
|
// remember to include : for namespaces
|
||||||
// basically just keep going until >, /, or whitespace
|
// basically just keep going until >, /, or whitespace
|
||||||
auto start = pos;
|
auto start = pos;
|
||||||
while( data[pos] != '>' && data[pos] != '/' && data[pos] != '=' &&
|
while(data[pos] != '>' && data[pos] != '/' && data[pos] != '=' && !data[pos].isSimpleWhite)
|
||||||
data[pos] != ' ' && data[pos] != '\n' && data[pos] != '\t' && data[pos] != '\r')
|
|
||||||
{
|
{
|
||||||
if(data[pos] == '<') {
|
if(data[pos] == '<') {
|
||||||
if(strict)
|
if(strict)
|
||||||
|
@ -489,15 +487,15 @@ class Document : FileResource {
|
||||||
default:
|
default:
|
||||||
if(strict)
|
if(strict)
|
||||||
parseError("Attributes must be quoted");
|
parseError("Attributes must be quoted");
|
||||||
// read until whitespace or terminator (/ or >)
|
// read until whitespace or terminator (/> or >)
|
||||||
auto start = pos;
|
auto start = pos;
|
||||||
while(
|
while(
|
||||||
pos < data.length &&
|
pos < data.length &&
|
||||||
data[pos] != '>' &&
|
data[pos] != '>' &&
|
||||||
// unquoted attributes might be urls, so gotta be careful with them and self-closed elements
|
// unquoted attributes might be urls, so gotta be careful with them and self-closed elements
|
||||||
!(data[pos] == '/' && pos + 1 < data.length && data[pos+1] == '>') &&
|
!(data[pos] == '/' && pos + 1 < data.length && data[pos+1] == '>') &&
|
||||||
data[pos] != ' ' && data[pos] != '\n' && data[pos] != '\t')
|
!data[pos].isSimpleWhite)
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
string v = htmlEntitiesDecode(data[start..pos], strict);
|
string v = htmlEntitiesDecode(data[start..pos], strict);
|
||||||
// don't skip the end - we'll need it later
|
// don't skip the end - we'll need it later
|
||||||
|
@ -4371,7 +4369,7 @@ class TextNode : Element {
|
||||||
string n = "";
|
string n = "";
|
||||||
bool lastWasWhitespace = indentationLevel > 0;
|
bool lastWasWhitespace = indentationLevel > 0;
|
||||||
foreach(char c; contents) {
|
foreach(char c; contents) {
|
||||||
if(c == ' ' || c == '\n' || c == '\r' || c == '\t') {
|
if(c.isSimpleWhite) {
|
||||||
if(!lastWasWhitespace)
|
if(!lastWasWhitespace)
|
||||||
n ~= ' ';
|
n ~= ' ';
|
||||||
lastWasWhitespace = true;
|
lastWasWhitespace = true;
|
||||||
|
@ -7092,6 +7090,10 @@ bool allAreInlineHtml(const(Element)[] children) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool isSimpleWhite(dchar c) {
|
||||||
|
return c == ' ' || c == '\r' || c == '\n' || c == '\t';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright: Adam D. Ruppe, 2010 - 2017
|
Copyright: Adam D. Ruppe, 2010 - 2017
|
||||||
License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
|
License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
|
||||||
|
|
Loading…
Reference in New Issue