aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2018-03-20 19:54:34 +0000
committerMichael Williamson <mike@zwobble.org>2018-03-20 19:54:34 +0000
commit08cade6674f38354f9bb6c3d1cb8359f7ca6d337 (patch)
tree33999a255b0b7b334b88cc7867db5ec4071be7fa /lib
parent31d2ad16c1a492cf0de0d5b6786f63496c01d78d (diff)
When using the pretty HTML writer, don't format HTML inside pre elements
Diffstat (limited to 'lib')
-rw-r--r--lib/writers/html-writer.js11
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,