cgiffard / Downsize

Tag safe text truncation for HTML and XML!
BSD 3-Clause "New" or "Revised" License
41 stars 13 forks source link

Tags with single quotes inside double quotes doesn't get parsed/truncated correctly according to the limit (by words/characters) #6

Closed aiampogi closed 10 years ago

aiampogi commented 10 years ago

Issue Summary

Tags with single quotes inside double quotes doesn't get parsed/truncated correctly according to the limit (by words/characters)

Steps to Reproduce

ddownsize('<p><img src="/someUrl.jpg" alt="Let\'s get in!"></p><p>hello world</p>', {words:"1"}); results to: '<p><img src="/someUrl.jpg" alt="Let\'s get in!"></p><p>hello world</p></p>'

But it should result to: '<p><img src="/someUrl.jpg" alt="Let's get in!"></p><p>hello</p>'

This is a bug because the specified number of html words should be followed even if the alt text of the has a single quote/apostrophe.

Technical details

directly related to: https://github.com/TryGhost/Ghost/issues/2106

aiampogi commented 10 years ago

Closing with a pull request https://github.com/cgiffard/Downsize/pull/7