Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
the only child text node has no whitespace on its sides
Browse files Browse the repository at this point in the history
  • Loading branch information
georgy7 committed May 27, 2017
1 parent 734a66d commit 3a33a1c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions source/lineml.d
Expand Up @@ -781,28 +781,32 @@ private string parseTreeToHtml(LineMLNode rootNode, LmlHtmlFormat format) {
while (stack.length > 0) {
auto current = stack[$-1];
if (current.childIndex == -1) {
if (format == LmlHtmlFormat.SPACES_4) {
if (format == LmlHtmlFormat.SPACES_4 &&
!(stack.length >= 2 && stack[$-2].node.children.length == 1 && stack[$-1].node.textContent)) {
foreach (i; 0 .. (stack.length - 1)) {
result ~= spaces4Indent;
}
}
result ~= openTag(current.node);
if (stack[$-1].node.children.length > 0) {
if (format == LmlHtmlFormat.SPACES_4) {
if (format == LmlHtmlFormat.SPACES_4 &&
!(stack[$-1].node.children.length == 1 && stack[$-1].node.children[0].textContent)) {
result ~= "\n";
}
stack[$-1].childIndex++;
} else {
stack[$-1].childIndex = -2;
}
} else if (current.childIndex <= -2) {
if (format == LmlHtmlFormat.SPACES_4 && current.childIndex == -3) {
if (format == LmlHtmlFormat.SPACES_4 && current.childIndex == -3 &&
!(stack[$-1].node.children.length == 1 && stack[$-1].node.children[0].textContent)) {
foreach (i; 0 .. (stack.length - 1)) {
result ~= spaces4Indent;
}
}
result ~= closeTag(current.node);
if (format == LmlHtmlFormat.SPACES_4) {
if (format == LmlHtmlFormat.SPACES_4 &&
!(stack.length >= 2 && stack[$-2].node.children.length == 1 && stack[$-1].node.textContent)) {
result ~= "\n";
}
stack.length--;
Expand Down

0 comments on commit 3a33a1c

Please sign in to comment.