diff --git a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java
index 27273a3298..068c43a2a7 100644
--- a/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java
+++ b/gerrit-prettify/src/main/java/com/google/gerrit/prettify/common/PrettyFormatter.java
@@ -381,15 +381,17 @@ public abstract class PrettyFormatter {
}
private SafeHtml showTabAfterSpace(SafeHtml src) {
- src = src.replaceFirst("^( *\t)", "$1");
- src = src.replaceAll("\n( *\t)", "\n$1");
+ final String m = "( ( |]*>|)*\t)";
+ final String r = "$1";
+ src = src.replaceFirst("^" + m, r);
+ src = src.replaceAll("\n" + m, "\n" + r);
return src;
}
private SafeHtml showTrailingWhitespace(SafeHtml src) {
final String r = "$1$2";
- src = src.replaceAll("([ \t][ \t]*)(\r?\n)", r);
- src = src.replaceFirst("([ \t][ \t]*)(\r?\n?)$", r);
+ src = src.replaceAll("([ \t][ \t]*)(\r?()?\n)", r);
+ src = src.replaceFirst("([ \t][ \t]*)(\r?()?\n?)$", r);
return src;
}
}
diff --git a/gerrit-prettify/src/main/resources/com/google/gerrit/prettify/client/gerrit.css b/gerrit-prettify/src/main/resources/com/google/gerrit/prettify/client/gerrit.css
index ff9e35a354..cf39d221aa 100644
--- a/gerrit-prettify/src/main/resources/com/google/gerrit/prettify/client/gerrit.css
+++ b/gerrit-prettify/src/main/resources/com/google/gerrit/prettify/client/gerrit.css
@@ -26,13 +26,23 @@
border-left: 1px dotted red;
}
-.wse .vt {
- border-left: 2px dotted black;
-}
-
.wdd {
background: #FAA;
}
.wdi {
background: #9F9;
}
+
+/* Use special rules for special styles contained within a whitespace
+ * error. For these we want the whitespace error to take precedence
+ * so we have to override the contained style.
+ */
+.wse .vt {
+ border-left: 2px dotted black;
+}
+.wse .wdd {
+ background: red;
+}
+.wse .wdi {
+ background: red;
+}