![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
amphtml-validator
Advanced tools
Readme
To install this as a command line tool, type npm install -g amphtml-validator
.
Now let's validate a real AMP HTML page.
$ amphtml-validator https://www.ampproject.org/
https://www.ampproject.org/: PASS
How about an empty file? Turns out an empty file is not valid AMP.
$ echo > empty.html
$ amphtml-validator empty.html
empty.html:1:0 The mandatory tag 'html doctype' is missing or incorrect.
empty.html:1:0 The mandatory tag 'html ⚡ for top-level html' is missing or incorrect. (see https://www.ampproject.org/docs/reference/spec.html#required-markup)
empty.html:1:0 The mandatory tag 'head' is missing or incorrect. (see https://www.ampproject.org/docs/reference/spec.html#required-markup)
...
OK, let's try a better starting point. Let's verify that this document is valid AMP.
$ amphtml-validator https://raw.githubusercontent.com/ampproject/amphtml/master/validator/testdata/feature_tests/minimum_valid_amp.html
https://raw.githubusercontent.com/ampproject/amphtml/master/validator/testdata/feature_tests/minimum_valid_amp.html: PASS
Great, we download it and edit it. You may use vim
if you don't like Emacs.
$ wget --output-document=hello-amp.html https://raw.githubusercontent.com/ampproject/amphtml/master/validator/testdata/feature_tests/minimum_valid_amp.html
$ amphtml-validator hello-amp.html
hello-amp.html: PASS
$ emacs hello-amp.html
To install, use npm install amphtml-validator
in your project directory,
or add amphtml-validator
as a dependency to your package.json.
This API is new and still experimental, feedback is especially welcome.
You may save the following example into a file, e.g., demo.js
.
'use strict';
const ampValidator = require('amphtml-validator');
ampValidator.getInstance().then((validator) => {
const result = validator.validateString('<html>Hello, world.</html>');
((result.status === 'PASS') ? console.log : console.error)(result.status);
for (const error of result.errors) {
let msg = 'line ' + error.line + ', col ' + error.col + ': ' + error.message;
if (error.specUrl !== null) {
msg += ' (see ' + error.specUrl + ')';
}
((error.severity === 'ERROR') ? console.error : console.warn)(msg);
}
});
Now try running it:
$ node demo.js
FAIL
line 1, col 0: The mandatory attribute '⚡' is missing in tag 'html ⚡ for top-level html'. (see https://www.ampproject.org/docs/reference/spec.html#required-markup)
line 1, col 0: The parent tag of tag 'html ⚡ for top-level html' is '$root', but it can only be '!doctype'. (see https://www.ampproject.org/docs/reference/spec.html#required-markup)
...
As expected, this emits errors because the provided string in the example, <html>Hello, world.</html>
is not a valid AMP HTML document.
FAQs
Official validator for AMP HTML (www.ampproject.org)
The npm package amphtml-validator receives a total of 28,861 weekly downloads. As such, amphtml-validator popularity was classified as popular.
We found that amphtml-validator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.