HTMLTidy is an open source utility for tidying up HTML. It is a command-line utility which is included in OS X. It is also used in my Plug-in for Coda. But Apple decided to include a quite old version (from 2006) – even in the current OS X 10.6 (Snow Leopard).
Since HTMLTidy has got some quite useful new features in the latest versions (like “preserve-entities“) and some bugfixes, this post explains how to install an updated version of HTMLTidy and how to use this with the Coda plug-in.
There are three different ways to accomplish this: You can try the binary I included here for download or use MacPorts or you can update by compiling your own version:
Method 1 – Downloading the binary (Use only if you’re afraid of the Terminal)
- Download this zip file » and unpack it.
- Copy the extracted file to your “Applications”-folder *
- Now the new version can be found in /Applications/tidy
Of course “/Applications” is not a very good location for a command line utility, but this is only for people who do not want to use the Terminal..
Method 2 – Using MacPorts
If you already use MacPorts that’s the most easy solution.
Open the terminal and enter this
sudo port install tidy
After MacPorts has downloaded and compiled the current version, you can find it in /opt/local/bin/tidy. (If you haven’t set up MacPorts to use another path)
Method 3 – Compiling a new version
If you know how to use the Terminal and navigate there, try this (in the Terminal):
cd /tmp cvs -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy login
Now you are asked for a password: Simply press return
cvs -z3 -d:pserver:anonymous@tidy.cvs.sourceforge.net:/cvsroot/tidy co -P tidy cd tidy/ sh ./build/gnuauto/setup.sh ./configure --prefix=/usr/local/ make sudo make install
Here you’ve got to enter your OS X password once.
Now the updated version can be found in /usr/local/bin/tidy
Configuring the Coda Plugin
Depending on which of the three methods you used, the new location for tidy is /Applications/tidy or /opt/local/bin/tidy or /usr/local/bin/tidy.
Now in Coda open “Plug-ins” ->”PHP & Web Toolkit” -> “Preferences” and copy this location to the field “Tidy binary”. That’s it.
I dont have a field for “Tidy Binary”???
Hi –
this post is somewhat outdated now, in the current plugin version the latest HTML tidy version is already included.
hi! can you tell me if there’s a way to customise how the HTML tidy works? i would love to switch off all the extra lines it puts in.
I assume in the Coda plugin..
So:
Modify the line “Indent: auto” to “Indent: yes”
Ok?
that worked, thanks!
as an aside, something seems to have gone wrong with the installation after the recent update. see screenshot here: http://i61.photobucket.com/albums/h48/zenkatydid/Screenshot2010-11-11at101242AM.png
That looks .. strange.
Have a look in this folder:
[your home folder]/Library/Application Support/Coda/Plug-ins/
and check if there’s more than one file starting with “PhpPlugin..”
If so, delete them and download/install again.
you’re absolutely right. each time i had downloaded an update, my computer had appended a number at the end of the file, and thus they had each been installed as separate plugins. i’ll just clear out my downloads folder, shall i? ;) thanks!
When i try the last method, i get an terminal reply: -bash: cvs: command not found
Is there something i’m doing wrong?
Cheers
Mario
Hi –
you need to install the Developer Tools for OSX (from the Installation DVD).
Thanks! After the DevTools install everything is ok …