django-htmlmin icon indicating copy to clipboard operation
django-htmlmin copied to clipboard

Non-breaking space breaks pyminify

Open cxxr opened this issue 11 years ago • 0 comments

Given this HTML file:

<html>
<head>
    <title>Test&nbsp;This</title>
</head>
<body>
    <h1>Test</h1>
    <p>Code:</p>
    <pre>
 a
   b
     c
    </pre>
    </body>
</html>

Then:

$ pyminify test.html
<html><head><title>Test This</title></head><body><h1>Test</h1><p>Code:</p><pre> a b c</pre></body></html>

Which is incorrect, as it doesn't format the pre tag correctly. When outputing to a file, the error is different:

$ pyminify test.html > output.html
Traceback (most recent call last):
  File "/usr/local/bin/pyminify", line 9, in <module>
    load_entry_point('django-htmlmin==0.6.2', 'console_scripts', 'pyminify')()
  File "/usr/local/lib/python2.7/dist-packages/htmlmin/commands.py", line 24, in main
    print html_minify(content, ignore_comments=not args.keep_comments)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 23: ordinal not in range(128)

cxxr avatar May 18 '13 22:05 cxxr