diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/html-writer.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/html-writer.js b/lib/html-writer.js index c144261..f1761c9 100644 --- a/lib/html-writer.js +++ b/lib/html-writer.js @@ -25,6 +25,7 @@ function prettyWriter() { var indentation = " "; var stack = []; var start = true; + var inText = false; var writer = simpleWriter(); @@ -48,7 +49,7 @@ function prettyWriter() { } function text(value) { - indent(); + startText(); writer.text(value.replace("\n", "\n" + indentation)); } @@ -58,7 +59,7 @@ function prettyWriter() { } function append(html) { - indent(); + startText(); writer.append(html.replace("\n", "\n" + indentation)); } @@ -66,7 +67,15 @@ function prettyWriter() { return stack.length === 0 || indentedElements[stack[stack.length - 1]]; } + function startText() { + if (!inText) { + indent(); + inText = true; + } + } + function indent() { + inText = false; if (!start && insideIndentedElement()) { writer.append("\n"); for (var i = 0; i < indentationLevel; i++) { |
