If you'd like to use the web UI, simply visit validator.amp.dev.
In this directory, run
$ npm install
$ go build serve-standalone.go
$ ./serve-standaloneThen visit your own instance at http://127.0.0.1:8765/.
If you'd like to run exactly the code that is running at validator.amp.dev, that's an Appengine app - please refer to the instructions in serve.go.
This tool will also accept a document passed in via the URL as part of the URL hash. It expects the format #doc=<ENCODED_DOCUMENT>. This allows users to construct an link that will auto-populate the tool with the incoming document.
To use this feature you must first base64 encode the HTML string. Due to unicode problems with the native btoa() function, this tool expects the string to be encoded using the following solution from mdn:
// ucs-2 string to base64 encoded ascii
function utoa(str) {
return window.btoa(unescape(encodeURIComponent(str)));
}By default this tool will assume you want to validate an AMPHTML document. If you would like to validate another format you can chose one of the following:
#htmlFormat=AMP4ADS
#htmlFormat=AMP4EMAILIf you wish to use both the doc= and htmlFormat= together make sure to include an & between the key-value pairs.
Putting it all together allows you to create links like this example.