Skip to content

Latest commit

 

History

History
70 lines (52 loc) · 2.98 KB

README.md

File metadata and controls

70 lines (52 loc) · 2.98 KB

AMP HTML ⚡ Validator

A validator for the AMP HTML format.

If you just want to validate a page that you're looking at in your web browser, add #development=1 to your URL and look for the validation messages in the Javascript console. See also our documentation over at ampproject.org.

For the additional choices listed below, install Node.js version 4.X on your system (tested with v4.4.2). E.g., by downloading or by using a package manager or by using NVM.

Node.js based command line tool and API

Please see (https://github.com/ampproject/amphtml/blob/master/validator/nodejs/README.md).

Web UI

Please see (https://github.com/ampproject/amphtml/blob/master/validator/webui/README.md).

Building a Custom Validator

This is only useful for development - e.g. when making changes to validator.js, and it's rough aroung the edges. Below are instructions for Linux Ubuntu 14.

Install these packages using apt-get:

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

In addition, install Node.js version 4.X on your system (tested with v4.4.2). E.g., by downloading or by using a package manager or by using NVM.

Then, run build.py. This creates dist/validator_minified.js, which is equivalent to the validator deployed at cdn.ampproject.org. You may now use the --validator_js command line flag to index.js to use this validator.

$ node nodejs/index.js --validator_js dist/validator_minified.js testdata/feature_tests/several_errors.html
testdata/feature_tests/several_errors.html:23:2 The attribute 'charset' may not appear in tag 'meta name= and content='.
testdata/feature_tests/several_errors.html:26:2 The tag 'script' is disallowed except in specific forms.
testdata/feature_tests/several_errors.html:32:2 The mandatory attribute 'height' is missing in tag 'amp-img'. (see https://www.ampproject.org/docs/reference/amp-img.html)
testdata/feature_tests/several_errors.html:34:2 The attribute 'width' in tag 'amp-ad' is set to the invalid value '100%'. (see https://www.ampproject.org/docs/reference/amp-ad.html)
...