Lullabot / amp-library

Convert HTML to AMP HTML and report HTML compliance with the AMP HTML specification
Other
381 stars 178 forks source link

inline style removed from div block #268

Closed justid closed 4 years ago

justid commented 4 years ago
function myfunc() { 
   $amp = new Lullabot\AMP\AMP();
    $amp->loadHtml('<div style = "color:green;margin-left:30px;">test</div>');
    return $amp->convertToAmpHtml();
}

output:

<div>test</div>

I was so confused, why is that?I thought inline-style was legally in AMP page.

justid commented 4 years ago

Line 1: <div>test</div>

ORIGINAL HTML
---------------
Line 1: <div style="color:green;margin-left:30px;">test</div>

AMP-HTML Validation Issues and Fixes
-------------------------------------
FAIL

<div style="color:green;margin-left:30px;"> on line 1
- The attribute 'style' may not appear in tag 'div'.
   [code: DISALLOWED_ATTR  category: DISALLOWED_HTML]
   ACTION TAKEN: div.style attribute was removed due to validation issues.
justid commented 4 years ago

I fixed this in my repo

ghost commented 3 years ago

I also need this, and as you said based on the AMP documentation it is valid, so I propose to create a PR for this.