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 `- text
- text
`, 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 ~= "";
s ~= tagName;
@@ -5117,12 +5118,17 @@ struct DomMutationEvent {
}
-private enum static string[] selfClosedElements = [
+private immutable static string[] selfClosedElements = [
// html 4
"img", "hr", "input", "br", "col", "link", "meta",
// html 5
"source" ];
+private immutable static string[] inlineElements = [
+ "span", "strong", "em", "b", "i", "a"
+];
+
+
static import std.conv;
///.
@@ -7044,6 +7050,21 @@ unittest {
assert(stringplate.expand.innerHTML == `
`);
}
+/
+
+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.