summaryrefslogtreecommitdiff
path: root/coverage/html.py
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
commit0a792695acfa3a0c2a150d2164317a71563d8e82 (patch)
treed9cf9b086fdcdd4478acdf7685fffadd23c4cdf9 /coverage/html.py
parenta731a1b98bae1ed779a8dac5c89c203dbc7842ec (diff)
downloadpython-coveragepy-0a792695acfa3a0c2a150d2164317a71563d8e82.tar.gz
Use whitespace:pre to avoid having to convert spaces in the HTML report. Fixes #472.
Diffstat (limited to 'coverage/html.py')
-rw-r--r--coverage/html.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/coverage/html.py b/coverage/html.py
index 8dca632..6a2132b 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):