diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/writers/html-writer.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/writers/html-writer.js b/lib/writers/html-writer.js index ee7d49f..e16feec 100644 --- a/lib/writers/html-writer.js +++ b/lib/writers/html-writer.js @@ -53,7 +53,8 @@ function prettyWriter() { function text(value) { startText(); - writer.text(value.replace("\n", "\n" + indentation)); + var text = isInPre() ? value : value.replace("\n", "\n" + indentation); + writer.text(text); } function selfClosing(tagName, attributes) { @@ -79,7 +80,7 @@ function prettyWriter() { function indent() { inText = false; - if (!start && insideIndentedElement()) { + if (!start && insideIndentedElement() && !isInPre()) { writer.append("\n"); for (var i = 0; i < indentationLevel; i++) { writer.append(indentation); @@ -87,6 +88,12 @@ function prettyWriter() { } } + function isInPre() { + return _.some(stack, function(tagName) { + return tagName === "pre"; + }); + } + return { asString: writer.asString, open: open, |
