MCPcopy Create free account
hub / github.com/ampproject/amphtml / posthtmlGetAmpFormat

Function posthtmlGetAmpFormat

build-system/tasks/validate-html-fixtures.js:28–42  ·  view source on GitHub ↗

* @param {posthtml.Node} tree * @return {string}

(tree)

Source from the content-addressed store, hash-verified

26 * @return {string}
27 */
28function posthtmlGetAmpFormat(tree) {
29 let format = defaultFormat;
30 tree.match({tag: 'html'}, (node) => {
31 for (const prefix of formatPrefixes) {
32 for (const suffix of formatSuffixes) {
33 const attrValue = node.attrs[prefix + suffix];
34 if (attrValue === '' || attrValue === true) {
35 format = 'AMP' + suffix.toUpperCase();
36 }
37 }
38 }
39 return node;
40 });
41 return format;
42}
43
44/**
45 * Gets the AMP format type for the given HTML file by parsing its contents and

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected