DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS

OSXFAQ Mac OS X UNIX Tip-of-the-Day   back to index

Week

by Adrian Mayo - Editor, OSXFAQ

Friday - Tidy with Tidy

Tidy is a utility to syntax check and tidy HTML source code. Type:

$ tidy -h

to see a help screen.

See sourceforge. Tidy can be installed in earlier versions of Mac OS X from sourceforge and presumably other ports like Fink and DarwinPorts.

If you're into the vim editor, tidy can be used to great effect to check and tidy HTML source files directly within vim. Add the following file type plugin for html files.

$ cat ~/.vim/ftplugin/html/tidy.vim 
""""""""""""""""""""""""""""""""""""""""""""""
" Adrian's vim filetype plugin for html tags "
""""""""""""""""""""""""""""""""""""""""""""""
"
" Maintainer:  Adrian Mayo
" URL:         http://www.mayo-family.com/vim/ftplugin/html/tidy.vim
" MAIN URL:    http://www.mayo-family.com/vim
"
" This file defines maps to call the html tidy program, see:
"   http://tidy.sourgeforge.net/
"
" This file should be placed in ~/.vim/ftplugin/html/ on Unix systems
"   and will automatically be sourced for filetype = html.
"

" Map to check html and display error in a new window " noremap \err :1<CR>yG :20new<CR>p :setfiletype html<CR> :%!tidy -i >/dev/null<CR>
" Map to tidy html " noremap \tidy :%!tidy -i -f /dev/null<CR>
" END "

The new commands are invoked by typing \err and \tidy in normal mode.


Visit the Site of the Book of the Unix Tips:
Projects 32, 33, 34, 35 cover the vim editor in detail.


Discuss this trick in the Learning Center forum


Copyright © 2000-2010 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.