HTML Spell Check

In this example, we do an HTML spell check using the =spelling_errors() script macro.

spelling_errors(site, SITE)

	init
		status =piktstatus
		level =piktlevel
		task "Report spelling errors in html files"
		input proc "for f in `find =httpd_doc_root/(site)
                                           -name \\*.htm\\* -print`;
                            do echo $f; /usr/local/bin/spell_check.pl -d
                                        =objdir/(SITE)Dictionary.obj -f $f;
                            done"

	begin
		set #havewords = #false()

	rule
		set #isword = #false()

	rule	// determine if file or word
		if $left($inlin, 1) eq "/"
			set $file = $inlin
			=chomp($file, $newline())
#ifdef debug
			output "file: $file"
#endifdef
		else
			set $word = $inlin
			=chomp($word, $newline())
			set #isword = #true()
#ifdef debug
			output "word: $word"
#endifdef
		fi

	rule	// bypass one-, two-, and three-letter words
		if #length($word) <= 3
			next
		fi

	rule	// if word, output file and word
		if #isword
			output mail "$file:  $word"
			=incr(#counts[$word])
			set #havewords = #true()
		fi

	end
		if #havewords
			output mail =newline
			foreach #keys($w, #counts)
				output mail $w
			endforeach
			output mail =newline
			output mail "review, add to dictionary_objects.cfg, then do:
                                     piktc -iv +O (SITE)Dictionary +H (site)web"
		fi

In the =spelling_errors() script macro, note how it uses a Perl script, spell_check.pl, for its input.

We might invoke the =spelling_errors() macro in our alarms.cfg (or one of its #include files) file thusly:

///////////////////////////////////////////////////////////////////////////////
 
SpellingErrorsPIKT
 
	=spelling_errors(pikt, PIKT)
 
///////////////////////////////////////////////////////////////////////////////
 
SpellingErrorsEMC
 
	=spelling_errors(emc, EMC)
 
///////////////////////////////////////////////////////////////////////////////

The ReportPIKTSpellingErrors script might send an alert message like the following:

                                PIKT ALERT
                         Mon Jul 26 20:49:19 2004
                                 calgary
INFO:
    SpellingErrorsPIKT
        Report spelling errors in html files

        spellng
        mesage

        review, add to dictionary_objects.cfg, then do:  piktc -iv +O PIKTDictionary +H piktweb

This is just one program example.  You could add rules, or write new scripts, for example to:  automatically update certain web pages, report HTML coding errors, report broken links, etc.

For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
google_ad_client
error
Pikt script