I adapted this as a text-filter in BBEdit, and one issue I ran into is that BBEdit often supplies files with unicode text in them. The filters work fine on this, but when print is called at the end it chokes on the non-ascii character set. A quick .encode('utf-8') fixes this.
Relevant blog post (re BBEdit text filter): http://objectivesea.tumblr.com/post/9700437213/jsbeautifierforbbedit
fixed unicode bug. print needs encoding specified if it has unicode i…
This is not good, as it breaks output under python3:
% echo 'var a = 5, b = 6' | python2 python/jsbeautifier.py -
var a = 5,
b = 6
% echo 'var a = 5, b = 6' | python3 python/jsbeautifier.py -
b'var a = 5,\n b = 6'
Ah, of course.
I can't seem to duplicate my unicode issues with anything but BBEdit anyway, so perhaps it's only applicable to that.
Thanks for the quick response. If I figure a way to solve this without breaking python 3 I'll send another pull request.
Could you provide a test case or a source file which gets choked? So that we could investigate the issue.
Also note that JSB has undergone so many changes, so checkout the very last git revision and check that it still applies.
Accept input via argv or stdin, depending (argv trumps stdin)
Is this still open?
Closing as inactive