HOME        PACKAGES        SCRIPTS

tidy.sh

Here is the script I personally use to run tidy. It directs only the error listing to the console, and enables tidy to create two files, one being the error listing and the other being the corrected markup.

Note that if you want to use this script on another operating system, you will need to change the path to tidy from /home/QtPalmtop/bin/tidy to either just "tidy" if your system recognizes it as a command, or substitute the full path to tidy on your particular system in the script.

For my discussion of tidy and tidy resources, click here. If you want to download an html-free copy of the script, click here.

If you want to see a translation engine friendly version of this page, with the code remaining intact but the explanations translated, click here for altavista's rendition. If you have another translation engine that honors html <code> tags, then click here. I recommend altavista because I could not get google to pay attention to my <code> tags.

 
#!/bin/bash

# tidy.sh uses tidy to process a file which
# must be given as the first argument on the
# command-line.  
# It outputs a list of errors to the console
# and puts a copy of the list in $1.tidy-err.tmp.
 
/home/QtPalmtop/bin/tidy -q -f /tmp/html-err.tmp -O $1.tmp $1 

# I use sed to sort the output by line number.
# My script only partially sorts the output
# but I haven't taken the time to change it as
# it works well enough for me as it stands.  
#
#  the following could possibly be replaced by:
# s/e \([1-9]\) /e 0\1/ 
# or
# sed -e '/e 1 /s//e 01 /;/e 2 /s//e 02 /;/e 3 /s//e 03 /;/e 4 /s//e 04 /;/e 5 /s//e 05 /;/e 6 /s//e 06 /;/e 7 /s//e 07 /;/e 8 /s//e 08 /;/e 9 /s//e 09 /' /tmp/html-err.tmp | sort | tee $1.tidy-err.tmp | more 

# the following works on ROM 2.38.  sed versions
# vary so you may have to tweak for other ROMs
# or to use the busybox version of sed.

sed -e 's/line //'  /tmp/html-err.tmp | sort -n | sed -e 's/^/line /' | tee $1.tidy-err.tmp | more 
rm /tmp/html-err.tmp 2> /dev/null
exit



 

Revised November 16, 2012