为什么我会收到这个错误?我使用wordpress和自动AMP插件。
标签'head >styleamp样板‘内的强制文本(CDATA)丢失或不正确。MANDATORY_AMP_TAG_MISSING_OR_INCORRECT第1行,第473栏
标签'noscript >styleamp样板‘中的强制文本(CDATA)丢失或不正确。MANDATORY_AMP_TAG_MISSING_OR_INCORRECT第10行,第19栏
<!doctype html><html amp lang="tr-TR"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"><title>Example</title><link rel="canonical" href="http://www.example.com/okul-kombinleri/" /> <script src="https://cdn.ampproject.org/v0.js" async></script> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic"><style amp-boilerplate>body {
-webkit-animation:0 8s steps(1,end) 0 1 normal both;
-moz-animation:0 8s steps(1,end) 0 1 normal both;
-ms-animation:0 8s steps(1,end) 0 1 normal both;
animation:0 8s steps(1,end) 0 1 normal both;
}
to {
visibility:visible;
}</style><noscript><style amp-boilerplate>body {
-webkit-animation:none;
-moz-animation:none;
-ms-animation:none;
animation:none;
}</style></noscript>
发布于 2018-04-30 16:05:51
根据AMP HTML规范,我认为需要从AMP样板代码中删除所有新行,因为它是用regex (正则表达式)验证的,因此所有新行都被读取为"\n“,从而导致错误。
直接从docs
安培样板代码(“头”>“模版-样板”和“noscript”“样板-样板”) AMP HTML文档必须在其头标记中包含以下样板。验证目前是用正则表达式完成的,因此保持尽可能少的突变是很重要的。目前,允许的突变是:(1)在样式标记打开后立即插入任意空格,并在关闭之前插入任意空格;(2)用任意空格替换下面代码段中的任何空格。
https://stackoverflow.com/questions/42260882
复制相似问题