kswedberg / jquery-expander

Expand and Collapse HTML content
https://kswedberg.github.io/jquery-expander/
Other
459 stars 167 forks source link

Issues with \n and white-space: pre-line; #116

Closed ZaneCEO closed 8 years ago

ZaneCEO commented 8 years ago

Hello, my webapp uses white-space: pre-line; to create linebreaks from the "\n" terminator even if the text has no BR or P.

It works as intended on its own, but as soon as I add jquery-expander to the text block it goes south: see my example here https://jsfiddle.net/sexyzane/4a0tuwuv/2/ and note how the second text block has the linefeed destroyed.

Any thoughts, workarounds or solutions? Thanks!

kswedberg commented 8 years ago

@ZaneCEO thanks for providing an example. I'll take a look as soon as I can. Feel free to ping me if you don't hear anything within a few days, though.

kswedberg commented 8 years ago

@ZaneCEO you're using a pretty old version of the plugin. Can you try it with the most recent version? I tested it locally, and it didn't seem to have a problem.

ZaneCEO commented 8 years ago

I'll test it immediately...

ZaneCEO commented 8 years ago

You are definitely right: as soon as I updated, the problem disappeard: https://jsfiddle.net/4a0tuwuv/3/

So... this is the second time that you solved a problem of mine. If you come to Ferrara (Italy), please stop by for a glass of wine: I definitely owe you one! Meanwhile, my sincere thanks!

kswedberg commented 8 years ago

Ha! Well, if I'm ever in the area, I just might take you up on the offer. :)

Happy to hear that it's working for you now.

ZaneCEO commented 6 years ago

Two years later, I come back to your plugin for another project. It still works like a charm, thanks!

A note to whoever may have my same problem with white-space not respected: you also need to set normalizeWhitespace: false in the config, like so:

        jQuery('#adv-description').expander({
            ...
            normalizeWhitespace: false
...
        });