rkazakov / ampify

Convert your HTML to Google AMP (Accelerated Mobile Pages)
MIT License
109 stars 32 forks source link

Cheerio Not Properly Handling Self Enclosed Tags #19

Closed gruberjl closed 6 years ago

gruberjl commented 6 years ago

Cheerio appears to have a bug which is affecting this package. This package is changing the order or eliminating any sibling tags that come after an img.

// Ampifying this
<div><p>1</p><img src="image.png" width="300" height="200"><p>2</p></div>

// Results in
<div><p>1</p><img src="image.png" width="300" height="200"></div>

index.js line 167 can be replaced with the following to fix it:

$(element).html($(ampElement).html());

PR incoming