HTML-Tidy Gedit Plugin

Purpose

When editing HTML it's easy to make mistakes. Wouldn't it be nice if there was a simple way to fix these mistakes automatically and tidy up sloppy editing into nicely layed out markup? Dave Raggett's HTML Tidy is a free utility for doing just that.

This is an HTML Tidy plugin for gedit, the default text editor for the Gnome Desktop. Once activated, this plugin allows:

Download, Install, and Activate

First, please make sure that HTML Tidy is installed on your system (e.g., via sudo apt-get install tidy). Following that, you can download, install, and activate the plugin using the following steps:

  1. Download html-tidy-gedit-plugin.tar.gz, and extract the contents to gedit's plugin directory (typically, ~/.gnome2/gedit/plugins/).
  2. Restart gedit.
  3. Select Edit → Preferences → Plugins. Check the plugin as in the next screenshot. Activating the Plugin

Use

The following screenshot shows a very basic HTML example. We'll see Checking for Problems and Correcting Problems.

A Simple HTML Document

Checking for Problems

To check for problems, select Tools → Tidy Check. The bottom pane (which can be shown through Ctrl + F9) will show the problem report. Clicking on a row in the bottom pane will place the insert cursor at the location of the corresponding problem. The following screenshot shows a report for two problems: a missing <!Doctype> declaration, and a missing title element.

The Document Checked

Correcting Problems

If you are reasonably pleased with your document, you might trust Tidy to correct it by selecting Tools → Tidy. The following screenshot shows the result.

The Document Tidied

Note that Tidy inserted some stuff, like the empty <title></title> pair. This empty title might not be what your page needs, but no HTML validity check will indicate further problems with the title element. You might consider, therefore, first Checking for Problems.

Configure

Accessing the Configuration Dialog

You can access the configuration dialog in one of two (equivalent) ways:

  1. Select Edit → Preferences → Plugins, highlight this plugin, and click Configure Plugin.
  2. Selecte Tools → Configure Tidy...

The following screenshot shows the configuration dialog:

Configure

Now we have the configuration dialog, which has just two frames. We'll cover them in Setting HTML Tidy's Options and Setting the File Types.

Setting HTML Tidy's Options

HTML Tidy comes with quite a few configuration options. You can set them using the radio options in the configuration dialog's HTML Tidy Options frame:

Setting the File Types

Suppose you're editing a Python source, your LaTeX thesis, or just a (non-HTML) suicide note. You probably don't want to run HTML Tidy on these, and it would be nice if the relevant actions (Tools → Tidy and Tools → Tidy Check) were just disabled when you do this. You can set this using the radio options in the configuration dialog's File Types frame: