cgiffard / Downsize

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

Fix to correctly parse single quotes found in a double quote strings #7

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

closed issue number 7 and opened this pull request instead

cgiffard commented 10 years ago

Thanks! Reviewing now.

cgiffard commented 10 years ago

I did a manual merge. Thanks again!

aiampogi commented 10 years ago

Glad to help!