Thomas
Thomas

Reputation: 5856

Validating HTML from the command line

I'm a web developer who is increasingly using Vim to code web sites. Are there any HTML validation utilities (or techniques) out there that will take whatever file I'm working on and validate against its DOCTYPE without leaving the shell?

Upvotes: 26

Views: 9558

Answers (4)

serv-inc
serv-inc

Reputation: 38177

https://stackoverflow.com/a/45390674/1587329 pointed to the nodejs-package html-validator-cli. Use as

html-validator --verbose --file=path/to-file

The --verbose flag is optional.

This connects to w3c's server, but does so on the command-line.

Upvotes: 1

René Nyffenegger
René Nyffenegger

Reputation: 40499

Get yourself tidy from sourceforge and execute it on the shell
tidy -errors -q -f error_file.txt the_file.html

Edit July 2016: The source forge version is outdated (see @phihag's comment). Its successor can be found at http://www.html-tidy.org/ and https://github.com/htacg/tidy-html5.

The History page on ttp://www.html-tidy.org/ states:

In 2015 a group of concerned developers, users, and software integrators formed HTACG with the goal of revitalizing Tidy, which had fallen into a non-maintained state. As a W3C Community Group, HTACG was deemed worthy by the W3C, and W3C passed ownership of their project to HTACG, where it is currently being developed and prepped for a new, stable, and modern release.

Upvotes: 11

lutz
lutz

Reputation:

You can use tidy together with a small Vim script.

Upvotes: 10

G-Wiz
G-Wiz

Reputation: 7426

Try an XML validator with the appropriate Schema/DTD.

Here's a validator: http://xmlstar.sourceforge.net/

Various DTDs available here: http://www.w3.org/TR/xhtml1/dtds.html

Upvotes: 1

Related Questions