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

Spaces disappearing #68

Open
adamraider opened this issue Feb 5, 2016 · 2 comments · May be fixed by #69
Open

Spaces disappearing #68

adamraider opened this issue Feb 5, 2016 · 2 comments · May be fixed by #69

Comments

@adamraider
Copy link

In this series, we’re interviewing NYCDA graduates to talk about their program...
gets truncated to
In this series, we’re interviewingNYCDA graduates to talk about their program...

@ghost
Copy link

ghost commented Mar 9, 2016

The same happened to my use-case. I have been using markdown which i have later on truncated and it turns out that markdown processing left some new lines in HTML code which in turn truncate_html deleted.

I am currently working on a workaround...

@dwbutler
Copy link

I figured out what it was: non-breaking spaces (unicode 160). See http://www.rubyinside.com/the-split-is-not-enough-whitespace-shenigans-for-rubyists-5980.html

They are removed instead of being treated like regular spaces.

dwbutler added a commit to LevoLeague/truncate_html that referenced this issue May 25, 2016
This fixes the issue of non-breaking spaces being discarded, resulting in words being joined together. `\s` and `\S` only match on space (character 32). HTML often uses non-breaking spaces (character 160). A more general approach is to use `[[:space:]]` instead. According to the `Regexp` documentation, `[[:space:]]` matches "Whitespace character ([:blank:], newline, carriage return, etc.)"

Fixes hgmnz#68
@dwbutler dwbutler linked a pull request May 25, 2016 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants