From 51b6d237bbaf7fe19c073d80277b6b34187cca3e Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 1 Feb 2016 20:25:13 -0500 Subject: Use whitespace:pre to avoid having to convert spaces in the HTML report. Fixes #472. --- coverage/html.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'coverage/html.py') 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("&", "&").replace("<", "<").replace(">", ">") - .replace("'", "'").replace('"', """) - # Convert runs of spaces: "......" -> " . . ." - .replace(" ", "  ") - # To deal with odd-length runs, convert the final pair of spaces - # so that "....." -> " .  ." - .replace(" ", "  ") - ) + """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("&", "&").replace("<", "<") def spaceless(html): -- cgit v1.2.1