Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncating text with New Line Characters #63

Open
ssteeg opened this issue Apr 14, 2015 · 2 comments
Open

Truncating text with New Line Characters #63

ssteeg opened this issue Apr 14, 2015 · 2 comments

Comments

@ssteeg
Copy link

ssteeg commented Apr 14, 2015

Thanks for the work on this library. However, recently I noticed an issue where the truncation was failing and causing strange results. After some investigation, it was happening when the text contained a new line character - \n - and stripHTML: true, also lines: 2.

Example input:

This is a long line, it will cause things to start to wrap at some point, what is really happening though
This is a short line.

Output

p This is a long line, it will cause things to start to wrap at wra

I tried to trace the issue a bit and it seems like it's related to https://github.com/rviscomi/trunk8/blob/master/trunk8.js#L54 or #29. The new line character causes the HTML tags to not be properly open and closed. As a result, the stripped tag gets inserted into the truncated result.

My workaround fix was to strip any \n characters before passing the input to trunk8.

Thanks!

@dorilla
Copy link
Contributor

dorilla commented Jun 17, 2016

@ssteeg check this out #77 , I think it's better than stripping \n... let me know if this fixes your issue

@ssteeg-mdsol
Copy link

Thanks @dorilla. I no longer have access to the code where this issue was occurring, so I can't verify. However, it seems like a good step in the right direction 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants