Using Terminal To Tidy HTML Code 8

Terminal

Share
Using Terminal To Tidy HTML Code

Hey

I like writing in HTML code, its a simple programming language (if you can call it that) that offers you the ability to construct web pages for people to use. One of the most enjoyable parts of writing HTML from my point of view is making sure it is as efficient and as simple as possible. I also like having web structured code. One cool little app I have found is Tidy. Its run from Terminal, it doesn’t have many functions but is quite useful and for anyone who wants nice HTML code.

To access Tidy, open up Terminal. The following will indent all of your code so the nested elements are indent by one tab stop.

tidy -i test.html

This will create code that is well indented. Due to the way the program works you have to copy and paste the resultant code out of the Terminal window. I can’t find a simple method to copy the resulting code.

You can do more than indent code. If you replace “i” in the code above with -omit, it will omit additional tags. You can add -u to make tags to upper case. -e will show your errors which is very useful for finding problems and making sure you code is up to scratch. Finally -q will make the output be in quite mode, which means that any no-essential text will not be shown.

This tool is quite useful. To find out more information about it simply type “man tidy” into Terminal to see the manual page.

If Terminal is not up your street you can also use a Service menu item. Its called Tidy Service, and is designed to do a similar thing to the Terminal option.


If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

Where To Next?

  • Subscribe To Mac Tricks And Tips