summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-02-01 20:25:13 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-02-01 20:25:13 -0500
commit51b6d237bbaf7fe19c073d80277b6b34187cca3e (patch)
treef7a84f0c254997b8445cea2ab7b57504098ac791 /coverage
parente2e3e0f3f43535a2bccf432ca0f7bba6191faa8e (diff)
downloadpython-coveragepy-git-51b6d237bbaf7fe19c073d80277b6b34187cca3e.tar.gz
Use whitespace:pre to avoid having to convert spaces in the HTML report. Fixes #472.
Diffstat (limited to 'coverage')
-rw-r--r--coverage/html.py19
-rw-r--r--coverage/htmlfiles/style.css2
2 files changed, 8 insertions, 13 deletions
diff --git a/coverage/html.py b/coverage/html.py
index 8dca6323..6a2132b7 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -418,18 +418,13 @@ class HtmlStatus(object):
# Helpers for templates and generating HTML
def escape(t):
- """HTML-escape the text in `t`."""
- return (
- t
- # Convert HTML special chars into HTML entities.
- .replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
- .replace("'", "&#39;").replace('"', "&quot;")
- # Convert runs of spaces: "......" -> "&nbsp;.&nbsp;.&nbsp;."
- .replace(" ", "&nbsp; ")
- # To deal with odd-length runs, convert the final pair of spaces
- # so that "....." -> "&nbsp;.&nbsp;&nbsp;."
- .replace(" ", "&nbsp; ")
- )
+ """HTML-escape the text in `t`.
+
+ This is only suitable for HTML text, not attributes.
+
+ """
+ # Convert HTML special chars into HTML entities.
+ return t.replace("&", "&amp;").replace("<", "&lt;")
def spaceless(html):
diff --git a/coverage/htmlfiles/style.css b/coverage/htmlfiles/style.css
index 186b085b..4f43b591 100644
--- a/coverage/htmlfiles/style.css
+++ b/coverage/htmlfiles/style.css
@@ -226,7 +226,7 @@ td.text {
margin: 0;
padding: 0 0 0 .5em;
border-left: 2px solid #ffffff;
- white-space: nowrap;
+ white-space: pre;
}
.text p.mis {