linux poison RSS
linux poison Email

HTML Syntax Checker and Reformatter - Tidy

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? Well now there is! Dave Raggett's HTML TIDY is a free utility for doing just that. It also works great on the atrociously hard to read markup generated by specialized HTML editors and conversion tools, and can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities.

Tidy is able to fix up a wide range of problems and to bring to your attention things that you need to work on yourself. Each item found is listed with the line number and column so that you can see where the problem lies in your markup. Tidy won't generate a cleaned up version when there are problems that it can't be sure of how to handle. These are logged as "errors" rather than "warnings".

Installing Tidy:
Open up the terminal and type following command to install tidy under Ubuntu system:
$ sudo apt-get install tidy
Using Tidy:
Tidy also supports a configuration file, and this is now much the most convenient way to configure Tidy. Assuming you have created a config file named "config.cfg" (the name doesn't matter), you can instruct Tidy to use it via the command line option -config config.cfg

Below is the sample config file:
indent: auto
indent-spaces: 2
wrap: 72
markup: yes
output-xml: no
input-xml: no
show-warnings: yes
numeric-entities: yes
quote-marks: yes
quote-nbsp: yes
quote-ampersand: no
break-before-br: no
uppercase-tags: no
uppercase-attributes: no
char-encoding: latin1
new-inline-tags: cfif, cfelse, math, mroot,
  mrow, mi, mn, mo, msqrt, mfrac, msubsup, munderover,
  munder, mover, mmultiscripts, msup, msub, mtext,
  mprescripts, mtable, mtr, mtd, mth
new-blocklevel-tags: cfoutput, cfquery
new-empty-tags: cfelse
Below is the simple example of using tidy from command line with configuration file ...
tidy -config config.cfg -m test.html
-m option to get tidy to update the original file, and if the file is particularly bad



Check tidy man pages for more options.




0 comments:

Post a Comment

Related Posts with Thumbnails