summaryrefslogtreecommitdiff
path: root/coverage/html.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-05-04 21:47:17 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-05-04 21:47:17 -0400
commit2d4ebdde563b5a8abb0f9e3b499eef61bd66e8a5 (patch)
tree064a20fd1559c0cb3a3a9f13ef76cc1fc3cf8871 /coverage/html.py
parentba2ff067c0b68cd5f56004f99e1906dbca582030 (diff)
downloadpython-coveragepy-git-2d4ebdde563b5a8abb0f9e3b499eef61bd66e8a5.tar.gz
The HTMLifier didn't deal with runs of spaces with an odd number of spaces properly.
Diffstat (limited to 'coverage/html.py')
-rw-r--r--coverage/html.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/coverage/html.py b/coverage/html.py
index d34aeac7..6fc49ff5 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -132,8 +132,13 @@ class HtmlReporter(Reporter):
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; ")
)