Find file History
Latest commit 9b66415 Jan 13, 2017 @Gregable Gregable committed on GitHub Validator rollup (#7023)
* Disallow id="AMP" for all elements.

* More disallowed id and name attribute values.

* Remove old code for generating manufactured body tag warnings.

* Refactoring: Remove template_spec_url field from ParsedTagSpec; access validator rules via Context instance instead.

* Make the unused extension warning more descriptive.

* Revision bump for input change.

* `<amp-analytics>` is required by `<amp-access>`. Fix this warning message.

* Remove unused field.

README.md

AMP HTML ⚡ Validator

A validator for the AMP HTML format.

If you just want to validate a page, please see our documentation over at ampproject.org.

Chrome Extension

Please see chromeextension/README.md.

Command Line Tool and Node.js API

Please see nodejs/README.md.

Web UI

Please see webui/README.md.

Building a Custom Validator

This is only useful for development - e.g. when making changes to engine/validator.js or when authoring an AMP extension, and it's rough around 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 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 amphtml-validator to use this validator.

$ amphtml-validator --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)
...