From: Vladimír Vondruš Date: Sun, 3 Dec 2017 13:31:00 +0000 (+0100) Subject: css: strip trailing comments in postprocess.py. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=7e64bb4c3f6ec1efc04034b277de5d1d857e79fd;p=blog.git css: strip trailing comments in postprocess.py. Could get me back under 9 kB. --- diff --git a/css/postprocess.py b/css/postprocess.py index 555076f9..9ff78106 100755 --- a/css/postprocess.py +++ b/css/postprocess.py @@ -129,7 +129,12 @@ def postprocess(files): if in_variable_declarations: out.write(":root {\n") not_just_variable_declarations = True - out.write(line) + + # Strip the trailing comment, if there, to save some bytes + if line.rstrip().endswith('*/'): + out.write(line[:line.rindex('/*')]) + else: + out.write(line) # Now open the imported files and replace variables for file in imported_files + files[1:]: @@ -163,8 +168,12 @@ def postprocess(files): in_comment = True continue - # Something else, copy verbatim to the output - out.write(line) + # Something else, copy verbatim to the output. Strip the + # trailing comment, if there, to save some bytes + if line.rstrip().endswith('*/'): + out.write(line[:line.rindex('/*')].rstrip() + '\n') + else: + out.write(line) return 0