Installing a current version of HTMLTidy

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)

  1. Download this zip file » and unpack it.
  2. Copy the extracted file to your “Applications”-folder *
  3. 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.

10 Replies to “Installing a current version of HTMLTidy”

  1. 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.

    1. I assume in the Coda plugin..

      So:

      • – Open Plugins/PHP & Web Toolkit/Preferences, select the “HTML” tab
      • – Either choose as preset “Very Indented
      • – Or choose “Custom” and modify the configuration below:
        Modify the line “Indent: auto” to “Indent: yes

      Ok?

        1. 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.

          1. 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!

  2. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.