diff --git a/dom.d b/dom.d index c62e760..f8f25ae 100644 --- a/dom.d +++ b/dom.d @@ -3177,18 +3177,19 @@ class Element { // for simple `texttext`, let's // just keep them on the same line - if(children.length == 1 && children[0].nodeType == NodeType.Text && children[0].nodeValue.strip.length) - s ~= children[0].toString(); - else - foreach(child; children) { - assert(child !is null); + if(allAreInlineHtml(children)) { + foreach(child; children) { + s ~= child.toString(); + } + } else { + foreach(child; children) { + assert(child !is null); - s ~= child.toPrettyString(insertComments, indentationLevel + 1, indentWith); - } + s ~= child.toPrettyString(insertComments, indentationLevel + 1, indentWith); + } - // see comment above - if(!(children.length == 1 && children[0].nodeType == NodeType.Text && children[0].nodeValue.strip.length)) s ~= toPrettyStringIndent(insertComments, indentationLevel, indentWith); + } s ~= "
$foo
$baz
`); } +/ + +bool allAreInlineHtml(const(Element)[] children) { + foreach(child; children) { + if(child.nodeType == NodeType.Text && child.nodeValue.strip.length) { + // cool + } else if(child.tagName.isInArray(inlineElements) && allAreInlineHtml(child.children)) { + // cool + } else { + // prolly block + return false; + } + } + return true; +} + /* Copyright: Adam D. Ruppe, 2010 - 2017 License: Boost License 1.0.