welovewordpress / SublimeHtmlTidy

Tidy, clean and prettify your HTML code with this plugin for Sublime Text 2
GNU General Public License v2.0
88 stars 15 forks source link

Path Problems on Windows #6

Closed tqad closed 12 years ago

tqad commented 12 years ago

Hi,

there is a problem under Windows at the call of Tidy. I think the error comes from the deprecated os.system command, which has a strange behavior for quotes. I've fixed this by replacing it with subprocess.call and escape the quotes on line 77 (and 91, 103) retval = subprocess.call( '\"%s\" %s -q -m -f "%s" "%s"' % ( tidypath, arg2, tidyerrors, tmpfile ) )

Best regards Tariq

welovewordpress commented 12 years ago

Hi Tariq,

I just update the code to use subprocess.call, but I didn't escape the quotes since according to the docs, this should do effectively nothing, and I had to add the parameter shell=True, otherwise it would not run at all on my system.

Could you confirm that it runs on your system "out of the box", now? If you still need to escape the quotes to get it running, I will put them in, but it makes no sense and if it would, then it would be required for all the other quotes as well and not only the first two...

If you have any other problem, please post the log output that HtmlTidy generates. It might prove useful.

Thanks for your help,

Matt

tqad commented 12 years ago

Hi Matt,

I tried it without quotes, it seems that i misunderstood something, thx.

But the parameter shell=True doesn't work with my machine(windows 7). I'm not able to fix the error, this is what the console say:

HtmlTidy: invoked on file: C:\Users\tqad\workspace\TheWeek\test2.html HtmlTidy: buffer written to tmpfile: C:\Program Files\Sublime Text 2\Data\Packages/HtmlTidy/htmltidy-sublime-buffer.tmp HtmlTidy: use_tabs: False HtmlTidy: tab_size: 4 HtmlTidy: calling tidy: "C:\Program Files\Sublime Text 2\Data\Packages/HtmlTidy/win/tidy.exe" --indent-spaces 4 --wrap 150 --wrap-attributes 0 --new-blocklevel-tags "header, footer, article, section, hgroup, nav, figure, aside" --break-before-br 0 --indent-attributes 0 --indent 1 --tidy-mark 0 -q -m -f "C:\Program Files\Sublime Text 2\Data\Packages/HtmlTidy/htmltidy-error-log.tmp" "C:\Program Files\Sublime Text 2\Data\Packages/HtmlTidy/htmltidy-sublime-buffer.tmp" HtmlTidy: tidy returned error code: 1 HtmlTidy: tmpfile was processed and removed

Best regards Tariq

welovewordpress commented 12 years ago

But it does work, when you set shell=False ? I can only guess that it's required on Unix (OS X, Linux), but not on Windows. I can set this to False for Windows right in the script, of course. But could you confirm that it would work then, first?

Thanks

tqad commented 12 years ago

Yeah, setting the parameter shell=False works for me.

Best regards Tariq

welovewordpress commented 12 years ago

Ok, on windows platform is uses shell=False now, on everything else it is shell=True.

Should be fixed now.