Applescript for W3C validator

Summary:

For Mac users, one-step HTML validation for the current Safari or OmniWeb page.

If you’re the throw-caution-to-the-winds type who does design editing directly on your live website, these Applescripts might be useful. They send the URL of the current OmniWeb or Safari page to the W3C validator.

The OmniWeb script opens the validation results in a new tab or window, depending how you have set your OmniWeb preferences.

tell application "OmniWeb"
	set thisPage to address of active tab of browser 1 as string
	set theCommand to "php -r 'print(urlencode(\"" & thisPage & "\"));'"
	set thisEncodedPage to do shell script theCommand
	OpenURL "http://validator.w3.org/check?uri=" & thisEncodedPage & ¬ 
		"&charset=%28detect+automatically%29&doctype=Inline&group=0"
end tell 

The Safari version opens a new window. If you prefer a new tab, so far as I know you’ll have to GUI-script it.

tell application "Safari"
	set thisPage to URL of document 1 as string
	set theCommand to "php -r 'print(urlencode(\"" & thisPage & "\"));'"
	set thisEncodedPage to do shell script theCommand
	make new document at end of documents
	set URL of document 1 to "http://validator.w3.org/check?uri=" ¬
		& thisEncodedPage & ¬
		"&charset=%28detect+automatically%29&doctype=Inline&group=0"
end tell

Firefox and Camino are less Applescript-able. Again, I reckon it could be done with GUI scripting.

See also Check HTML syntax in BBEdit (revised).

Posted 2008-01-30 (last modified 2017-02-18)