Skip to content

Latest commit

 

History

History
 
 

validator

AMP HTML ⚡ Validator

A validator for the AMP HTML format.

This is a very first release, rough on the edges. Fasten your seatbelts.

Prerequisite: Linux Ubuntu 14 or similar, or Mac OS X 10.11.x or later

###Mac OS X

See Building a command-line AMP Validator: Mac OS X.

###Linux

Install these packages using apt-get:

  • npm
  • nodejs
  • openjdk-7-jre
  • protobuf-compiler
  • python-protobuf
  • python2.7

Then, run build.py. It creates dist/validate, a script which can print AMP HTML validation errors to the console.

$ dist/validate
usage: validate <file.html>
$ dist/validate testdata/minimum_valid_amp.html
PASS
$ touch empty.html
$ dist/validate empty.html
FAIL
empty.html:1:0 MANDATORY_TAG_MISSING html ⚡ for top-level html (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#ampd)
empty.html:1:0 MANDATORY_TAG_MISSING head (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#crps)
empty.html:1:0 MANDATORY_TAG_MISSING charset utf-8 declaration (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#chrs)
empty.html:1:0 MANDATORY_TAG_MISSING viewport declaration (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#vprt)
empty.html:1:0 MANDATORY_TAG_MISSING mandatory style (js enabled) opacity 0 (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#opacity)
empty.html:1:0 MANDATORY_TAG_MISSING mandatory style (noscript) opacity 1 (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#opacity)
empty.html:1:0 MANDATORY_TAG_MISSING noscript enclosure for mandatory style (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#opacity)
empty.html:1:0 MANDATORY_TAG_MISSING body (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#crps)
empty.html:1:0 MANDATORY_TAG_MISSING amphtml engine v0.js script (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#scrpt)